Here is a simplified CMakeLists.txt that I am using to cross-compile a shared library for Android.
cmake_minimum_required(VERSION 3.10)
project(MyTest)
link_directories($ENV{ANDROID_PREBUILT}/gcc/linux-x86/arm/arm-linux-androideabi-4.9/lib/gcc/arm-linux-androideabi/4.9)
add_library(MyTest SHARED MyTest.cpp)
When building, the error I get is:
xxx/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/arm-linux-androideabi-ld:
error: cannot find -lgcc
I see that the link directory I specified does have libgcc.a file.
Running make in verbose mode shows the following link command:
xxx/clang/host/linux-x86/clang-2690385/bin/clang++
--target=arm-linux-androideabi
--sysroot=xxx/ndk/current/platforms/android-23/arch-arm/usr
-fPIC -O3 -DNDEBUG -shared -Wl,-soname,libMyTest.so -o libMyTest.so
CMakeFiles/MyTest.dir/MyTest.cpp.o
It appears -L
flag is not getting generated by cmake.
If I directly run the above command with -L
flag, linking goes through fine and the shared library does get created.
Can someone please tell me what is it that I am missing?
Update:
I have tried exporting LIBRARY_PATH
as well as LDFLAGS
but both are being ignored.