Built for Android artifacts using CMake 3.7.0 rc cannot be executed on Android
Added in CMake 3.7.0 rc1/rc2 ability to build working artifacts for Android using NDK doesn't work. Actually, it is possible to build executable/library for needed architecture but in case of using these artifacts on android linking error is happened:
reloc_library[1474]: 1481 unknown reloc type 160 @ 0x9334 (4)CANNOT LINK EXECUTABLE
Seems that needed additional linker flags are absent. In my case, problem could be fixed by adding -Wl,--gc-sections flag for linker command.
Problem could be reproduced on building & running simple cmake hello world application for armeabi arch using c++_static STL.
Also, there is some another problem with linking on building for armeabi architecture:
/tmp/ndk-user/tmp/build-libc++/ndk/sources/cxx-stl/llvm-libc++/libcxx/include/atomic:922: error: undefined reference to '__atomic_fetch_add_4'
Seems that problem is happened because of incorrect linker order. As a workaround, next linker order could be specified to fix the problem:
target_link_libraries(ARTIFACT_NAME ${CMAKE_ANDROID_NDK}/sources/cxx-stl/llvm-libc++/libs/armeabi/thumb/libc++_static.a atomic)