I am trying to wrap me head around cross compiling C++ program for Android.
It is a simple console program.
My Cmake Configuration is like so:
cmake_minimum_required(VERSION 3.4.1)
project(app)
set(NDK "/Users/user/Desktop/NDK/toolchains/llvm/prebuilt/darwin-x86_64/bin")
set(CMAKE_CXX_FLAGS "")
set(CMAKE_C_COMPILER "${NDK}/clang")
set(CMAKE_CXX_COMPILER "${NDK}/armv7a-linux-androideabi16-clang++")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "../Output")
file(GLOB Source "Source/*.cpp")
add_executable(${PROJECT_NAME} ${Source})
compiling succeeds eventually I get linking error like so:
ld: error: unknown argument '-search_paths_first'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [../Output/app] Error 1
make[1]: *** [CMakeFiles/app.dir/all] Error 2
make: *** [all] Error 2
When I change armv7a-linux-androideabi16-clang++
compiler to clang++
, i get errors like this:
ld: error: unknown argument '-dynamic', did you mean '-Bdynamic'
ld: error: unknown argument '-arch'
ld: error: unknown argument '-platform_version'
ld: error: unknown argument '-syslibroot'
ld: error: unknown argument '-search_paths_first'
ld: error: unable to find library -lto_library
ld: error: cannot open /Users/user/Desktop/NDK/toolchains/llvm/prebuilt/darwin-x86_64/lib/libLTO.dylib: No such file or directory
ld: error: cannot open x86_64: No such file or directory
ld: error: cannot open macos: No such file or directory
ld: error: cannot open 11.0.0: No such file or directory
ld: error: cannot open 11.3: No such file or directory
ld: error: cannot open /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk: Is a directory
ld: error: CMakeFiles/app.dir/Source/Source.cpp.o: unknown file type
ld: error: unable to find library -lc++
ld: error: unable to find library -lSystem
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [../Output/app] Error 1
make[1]: *** [CMakeFiles/app.dir/all] Error 2
make: *** [all] Error 2
None of the binaries are in my search path, could this be the problem?