call C++ function from newlisp code

Started by csfreebird, October 21, 2013, 06:19:04 AM

Previous topic - Next topic

csfreebird

Is it possible to call a c++ function, I want to build a C++ so file which has some functions for accessing database, then write a newlisp app to use it. I am working on Ubuntu.

Lutz

#1
In your C++ programs you have to declare functions as extern "C". Then they can be imported into newLISP using either the simple or extended import interface.



Windows DLL:
extern "C" __declspec( dllexport ) int MyFunc(int a, int b);
or on other OS:
extern "C" int MyFunc(int a, int b);

csfreebird

#2
I made an example, see my blog

http://csfreebird.blogspot.com/2013/12/newlisp-accesses-mongodb-via-c-dynamic.html">http://csfreebird.blogspot.com/2013/12/ ... namic.html">http://csfreebird.blogspot.com/2013/12/newlisp-accesses-mongodb-via-c-dynamic.html



Thank you, Lutz.