How to link with an external library (custom native extension)? (SOLVED)

Hi there,

I start to write an external library under mac os environment and try to understand how the linking process is done. I made a simple XCode library project with only a single function :
int myAdd(int, int)
and build my project as a library file.
I put my library (.a file) under the “lib/x86_64-osx” folder in my basic defold project. I wrote a header file with extern C declaration :
extern "C" { int myAdd(int, int); }
I made a call to my simple function in my cpp file.
When I build my defold project, I got an “Undefined symbols for architecture x86_64” error for “_myAdd”. Do I need to make somewhere a reference to my library ?

Thanks

Did you read the native extension manual? https://defold.com/manuals/extensions/

Ok, thank you for your help.
My error comes from my library implementation (calling objective-c method with multiple parameters from C++).
I corrected and now, it works !

3 Likes