Page 1 of 1

call C++ function from newlisp code

Posted: Mon Oct 21, 2013 1:19 pm
by 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.

Re: call C++ function from newlisp code

Posted: Tue Oct 22, 2013 6:52 am
by Lutz
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:

Code: Select all

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

Code: Select all

extern "C" int MyFunc(int a, int b);

Re: call C++ function from newlisp code

Posted: Mon Dec 09, 2013 1:05 pm
by csfreebird
I made an example, see my blog
http://csfreebird.blogspot.com/2013/12/ ... namic.html

Thank you, Lutz.