0

I'm using VS 2019 v16.11.5 to compile and test an Android app.
All these libraries built and ran before I upgraded to 16.11. I had to go back and do some minor modifications and cannot get them to rebuild. One example is shown here.

I'm building a .so file and linking 5 *.a files and one *.so file. All six libraries have been completely rebuilt successfully. Library Dependencies are:
Support_Droid;Services_Droid;BaseLib_Droid;Common_Droid;_Linux;Interfaces_dynDroid;$(StlLibraryName)

The linker gives me:

undefined reference to 'Dictionary::get_string_translation(wchar_t*, wchar_t*, int, wchar_t const*)'    
undefined reference to 'attrVarIndex::getArrayPointer(itemBase*&)'
undefined reference to 'attrVarIndex::hCattrVarIndex(int, unsigned long)'

Running nm -C -g -u --defined-only libServices_Droid.a gives

00000088 T attrVarIndex::getArrayPointer(itemBase*&)  
00000000 W attrVarIndex::destroy()  
00000000 T attrVarIndex::attrVarIndex(int, unsigned long)  
00000000 T attrVarIndex::attrVarIndex(int, unsigned long)  
000000f8 T attrVarIndex::~attrVarIndex()  

Running nm -C -g -u --defined-only libSupport_Droid.a gives

00003f1c T Dictionary::get_string_translation(char*, char*, int)  
0000421c T Dictionary::get_string_translation(wchar_t const*, wchar_t*, int, wchar_t const*)  
0000400a T Dictionary::get_string_translation(wchar_t*, wchar_t*, int)  
000041d2 T Dictionary::get_string_translation(wchar_t*, wchar_t*, int, wchar_t const*) 

Setting ‘Enable Verbose Output’ to Yes in the Linker Options shows (in a bunch of tries):

Src\ARM\Debug/libSupport_Droid.a succeeded  
Src\ARM\Debug/libServices_Droid.a succeeded  
Src\ARM\Debug/libBaseLib_Droid.a succeeded  
Src\ARM\Debug/libCommon_Droid.a succeeded   
Src\ARM\Debug/lib_Linux.a succeeded 
Src\ARM\Debug/libInterfaces_dynDroid.so succeeded   
C:\\Microsoft\AndroidNDK64\android-ndk-r16b\sources\cxx-stl\llvm-libc++\libs\armeabi-v7a/libc++_shared.so succeeded 
C:\\Microsoft\AndroidNDK64\android-ndk-r16b\sources\cxx-stl\llvm-libc++\libs\armeabi-v7a/libc++abi.a succeeded  

in that order.

How is clang missing these few definitions out of the hundreds involved in this link? How can I trace the problem?

  • please show the full error message, I'm guessing a library order problem, `libSupport_Droid.a` needs to be listed after the libraries that use it – Alan Birtles Dec 02 '21 at 18:32
  • Alan Birtles - are you saying that the definition must be defined AFTER the usage of the function? I always thought it was the other way around, the definition must be linked BEFORE the usage. – Paul Winkle Dec 03 '21 at 03:13
  • Yes the linker goes through each library in turn collecting undefined symbols any unused symbols are discarded, the undefined symbols are then looked up in subsequent libraries – Alan Birtles Dec 03 '21 at 07:12
  • Alan - See https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix/24675715#24675715 – Paul Winkle Dec 03 '21 at 12:17
  • For anyone stumbling on this in the future: Alan is correct, clang expects the definition to be in or after item's declaration module. – Paul Winkle Dec 03 '21 at 13:54

0 Answers0