Android NDK Common Object Undefined Link Error

I had a strange problem trying to compile code for Android. My code for interacting with two third-party libraries (Libcurl and WebRTC), and when it falls into the connecting phase (linking to compiled common object files) reports that there are undefined references to functions within WebRTC, but Libcurl functions are excellent. Examples of undefined errors that I get are:

WS.cpp:208: error: undefined reference to 'buzz::XmlElement::AddAttr(buzz::QName const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)'

ThirdPartyLibs/WebRTC/src/third_party/android_tools/ndk/sources/cxx-stl/llvm-libc++/libcxx/include/memory:1636: error: undefined reference to 'buzz::QN_MESSAGE'

When I run the nm -CWebRTC library in a file and then the grepresults for the functions, the functions, as clearly shown, exist and are defined (in the text section).

nm -C Android/libs/armv7/libWebRTC.so | grep "AddAttr"
000753e5 t buzz::XmlElement::AddAttr(buzz::QName const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
0007541d t buzz::XmlElement::AddAttr(buzz::QName const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int)

nm -C kino/Android/libs/armv7/libWebRTC.so | grep "QN_MESSAGE"
000bfd10 d buzz::QN_MESSAGE

When I say that I am linking to a compiled WebRTC shared library, I should note that the shared library is compiled using either compiled static libraries, or related libraries, or object files. I am compiling using the following:

GCC_armv7=$projectDir/ThirdPartyLibs/WebRTC/src/third_party/android_tools/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc

OBJS_armv7="…list of static libraries or object files…"

LDFLAGS="-lc -ldl -lm -fPIC 
--sysroot=$projectDir/ThirdPartyLibs/WebRTC/src/third_party/android_tools/ndk/platforms/android-16/arch-arm 
-L$projectDir/ThirdPartyLibs/WebRTC/src/third_party/android_tools/ndk/platforms/android-16/arch-arm/usr/lib/"

$GCC_armv7 -v -shared $LDFLAGS -o libWebRTC.so -Wl,-soname=webrtc $OBJS_armv7

When I link my code directly to compiled ninja static library files or compiled ninja object files, I don't get the same errors. Since this works, it would be nice to just associate them with any of them. However, I told Java Android developers that although Java accepts static libraries, Android does not. And I can’t imagine that either Java or Android would get together with object files.

LOCAL_LDLIBS Android.mk , LOCAL_SHARED_LIBRARIES LOCAL_STATIC_LIBRARIES.

, ndk-build . , , libcurl libopenssl.

, nm | grep . nm –C | grep / .

static / object -
00000001 T buzz::XmlElement::AddAttr(buzz::QName const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)

shared object -
000753e5 t buzz::XmlElement::AddAttr(buzz::QName const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)

, nm, "T" "t", , .

, gcc ( g++) gcc/g++ , WebRTC (commit hash: aad6780e5c25b1622904ef83659461706f6a25db). ndk-build (ing) ndk-build, WebRTC (src/chromium/src/third_party/android_tools/ndk/ndk-build).

: , , - Android.mk , ,

: , ndk-build Android.mk gcc/g++, .

+4
1

. , WebRTC, . ndk-build . , .so . , WebRTC, . , , , ./libs/<arch>/ . , nm | grep , . - , ./obj/local/<arch>.

, - .

0

Source: https://habr.com/ru/post/1659422/


All Articles