0

In an Android project, we are using a static library (mainly boost) which is built on Mac, using clang and NDK 17. Under Mac, the project builds fine.

But now we have a developer that is working on Windows, and he gets a bunch of undefined reference errors, like the compiler is not finding the library:

C/C++: ../../../../../../libs/android/include\boost/filesystem/v3/operations.hpp:289: error: undefined reference to 'boost::filesystem3::detail::status(boost::filesystem3::path const&, boost::system::error_code*)'
C/C++: clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)

My understanding was that a static library for Android (for any cross-compiled platform actually) would work always, given that the compiler remains in the same version, no matter the host platform.

We are using NDK 17's clang and the project is setup with CMake. The project structure is the same in both systems, and the library is contained in a subfolder of the project.

So, assuming all compiler flags are the same, compiler version numbers are the same and the libraries are correctly found, my questions are:

  1. Can an Android library built on a Mac host be used from a Windows host using the same NDK version? Or must it be rebuilt?
  2. And more in general, can a library built in a cross-platform way on a particular host for a particular target, be used in a different host for the same particular target? Or must it be rebuilt?

Edit: The library is correctly included into the compiler command:

clang++.exe [...] lib/arm64-v8a/libboost_thread.a lib/arm64-v8a/libboost_system.a lib/arm64-v8a/libboost_filesystem.a [...]
LoPiTaL
  • 2,495
  • 16
  • 23
  • The linker is not finding the library, is it being linked correctly? Is it installed correctly on Windows some place where the linker will find it? – Quimby Sep 22 '22 at 09:12
  • @Quimby Yes, the project structure is exactly the same as in Mac, and the library is contained in a project's subfolder, so the linker should be able to find it in the same way as it finds it in the other system – LoPiTaL Sep 22 '22 at 09:18
  • 1
    [Print linker's search path](https://stackoverflow.com/questions/9922949/how-to-print-the-ldlinker-search-path?noredirect=1&lq=1) and make sure that the boost library (the compiled version) is on this path and make sure it contains the exported symbol for that function. – Quimby Sep 22 '22 at 09:28
  • @Quimby yes, the libraries are correctly in the path. Added the relevant linker call – LoPiTaL Sep 22 '22 at 10:15
  • Weird, try looking whether the libs do contain that symbol, maybe it has not been exported due to some mismatch. Not sure, sorry I have no more ideas as I am not that familiar with Android NDK. – Quimby Sep 22 '22 at 10:30

0 Answers0