ndk-build does not find symbols in .so file

48 views
Skip to first unread message

Kyle Cummings

unread,
Oct 27, 2016, 9:45:44 PM10/27/16
to android-ndk
I have been trying to compile C++ code for an Android application for a week now. I was able to get the project built and linked if I supply a static library file for one of the third party libraries. However, when I supply a shared object version of the same library, every function that I call in my code that exists in the so file suddenly errors with as an undefined reference. I run a 'nm | grep' command on the so file, and confirmed that the functions exist and are defined (with a lowercase 'd'). 

I have found that to get ndk-build to find the libraries (static or shared) I have to put the full path and filename in the LOCAL_LDLIBS parameter. If I do things the way I read you are supposed to (LOCAL_STATIC_LIBRARIES or LOCAL_SHARED_LIBRARIES), ndk-build does not appear to find the files and I get undefined references errors. 

The weird thing, though, is that another library that I am also using does not produce these errors. For reference, the third party libraries that I am using are: libcurl and WebRTC. The libcurl library .so file was built using the library's configure and make files. The WebRTC library so file is built by first using ninja to build the object and static library files, and then I have another script that compiles the .so file using either the static libraries or the all of the individual object files I need. 

Is there some special flags that need to be set, or a certain way that the the so file needs to be configured / built in order to be "compatible" with ndk-build or Android architectures?

For reference, I am building for the armeabi-v7a and arch-arm64 architectures.

I just had a thought to try and build my library with the WebRTC object files to see if those are good and it's just the so file that is bad. I will update the thread on the results.

Kyle Cummings

unread,
Oct 28, 2016, 7:19:57 PM10/28/16
to android-ndk
Okay, I have confirmed that providing the object files directly to the .mk file / ndk-build eliminates most of the undefined reference errors. 

Kwadwo Busumtwi

unread,
Oct 28, 2016, 7:20:25 PM10/28/16
to android-ndk
Sounds good :)

Been facing similar issues with the new build 
Reply all
Reply to author
Forward
0 new messages