Skip to content Skip to sidebar Skip to footer

Ndk-build: Undefined Reference To .. Errors When Statically Linking To Libxml.a

I get a lot of undefined reference to ... errors when I compile my single c++ source-file using the ndk-build tool. For the record I use NDK r6 on a linux host system. First of all

Solution 1:

Add the line

LOCAL_ALLOW_UNDEFINED_SYMBOLS := true

to the Android.mk file and it should work. As explained in the ndk doc, it is because the ndk performs a debug checking even for avoiding runtime linking error and for some motivations it doesn't find the correct references in a pre-built library. Hope it coulds help.

Solution 2:

You had to add APP_STL := stlport_static to the Application.mk file, not Android.mk.

EDIT: As far as I can see you haven't linked against stlport static library. So I think you should add something like -lstlport to LOCAL_LDLIBS.

Solution 3:

As others had mentioned,

LOCAL_ALLOW_UNDEFINED_SYMBOLS := true

will not work at run time. Have a look at this:

https://github.com/MysticTreeGames/Boost-for-Android

I ran into the same problem with boost (I use a custom 1.42 version).

Using the brute force method to configure gnustdc++ fixed my issue. The important thing is to link against -lgnustl_static (or whatever stl lib you use) after your libraries.

Solution 4:

The problem is that some functionalities are enabled by default while they may need some extra linking to other libraries , this functionalities are : - support loading MOD music via modplug . - support loading MOD music via mikmod - support loading MP3 music via SMPEG you should disable these options to build sdl2_mixer so go to "Android.mk" ( of SDL2_mixer) file and you will find :

SUPPORT_MOD_MODPLUG ?=true
...
SUPPORT_MOD_MIKMOD ?=true
...
SUPPORT_MP3_SMPEG ?=true

change those to "false" and it will work for you as did with me !

NOTES :

 LOCAL_ALLOW_UNDEFINED_SYMBOLS := true

1- will cause a runtime error , because the symbol will still not be resolved at runtime

2- You won't be able to load mp3 files but you can covert them to "ogg" with almost the same size and quality , but you can find the perfect solution of your exact problem here Runtime linking error with SDL_Mixer and SMPEG2 on Android

Solution 5:

Do you looked at the bug #16627 ?

http://code.google.com/p/android/issues/detail?id=16627

I'm running ndk-r8, but I'm still having those errors though.

Post a Comment for "Ndk-build: Undefined Reference To .. Errors When Statically Linking To Libxml.a"