newLISP Fan Club

Forum => newLISP in the real world => Topic started by: csfreebird on October 21, 2013, 06:19:04 AM

Title: call C++ function from newlisp code
Post by: csfreebird on October 21, 2013, 06:19:04 AM
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.
Title: Re: call C++ function from newlisp code
Post by: Lutz on October 21, 2013, 11:52:56 PM
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);
Title: Re: call C++ function from newlisp code
Post by: csfreebird on December 09, 2013, 05:05:05 AM
I made an example, see my blog

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



Thank you, Lutz.