Native extension build error (SOLVED)

Hello, I’m making a native extension but unfortunately the build server keeps returning an error as below:

Undefined symbols for architecture armv7:
  "_platform_setup", referenced from:
      __Z4initP9lua_State in lib20ca6ba8-02be-4dcb-ac22-031bca393893.a(extension_ios.cpp_1.o)

I created an iOS static library named libplatform.a and copied it to myextension/lib/ios/libplatform.a. I declared a C style function in it as below:

extern "C" void platform_setup(void*);

And called it in the native extension but I got the build error. The static library works correctly with an iOS test app in which the Objective C source calls platform_setup() by linking the static library. Am I missing something for build?

Thanks.

This error happens when you bundle for iOS? For which architectures are you bundling? 32 and 64 bit arm or just one of them?

1 Like

This is what I set for making iOS static library:

And this is the bundle settings on Defold:

2

Ok, and have you verified that the library contains the correct architectures? and symbol?

E.g.

$ lipo -info tmp/dynamo_home/lib/x86_64-darwin/libdlib.a
Non-fat file: tmp/dynamo_home/lib/x86_64-darwin/libdlib.a is architecture: x86_64
$ nm tmp/dynamo_home/lib/x86_64-darwin/libdlib.a | c++filt | grep Printf
no symbols
0000000000000000 T dmSnPrintf(char*, unsigned long, char const*, ...)
                 U dmSnPrintf(char*, unsigned long, char const*, ...)
                 U dmSnPrintf(char*, unsigned long, char const*, ...)
                 U dmSnPrintf(char*, unsigned long, char const*, ...)
                 U dmSnPrintf(char*, unsigned long, char const*, ...)

(ofc, substitute with your own paths/search strings)

1 Like

I didn’t try it and now I’ve got the info like this:
“Non-fat file: libplatform.a is architecture: arm64”

I wonder why it shows only arm64 even though I specified armv7 too on the Xcode build settings.
Anyway this helped a lot. Thanks.

1 Like

I’ve figured out the reason why Xcode built arm64 only. iOS Deployment Target was 13.0 as the default. I’ve made it lower and then now Xcode build armv7 as well.

3 Likes