I was trying to embed python into my Android App. So I need to build a bunch of C/C++ libraries besides the libpython3.x.a. Since Android NDK r21, the GCC toolchain is dropped and only clang as the default compiler. I have written some scripts to build some libraries and a little of patches. But in order to finish the project, I need more C/C++ libraries. So I switch to vcpkg. After some tests, I found that most libraries that are built with CMake seem to work well with the *-android triplets contributed by the community, but others that are based on autotools (e.g. configure + make) does not work well. For example, the libiconv failed during the config stage due to it is trying to compile with gcc.
There are several problems:
- the
VCPKG_DETECTED_CMAKE_CXX_STANDARD_LIBRARIES contains -static-libc++ which will be convert to -l-static-libc++ since it is not the standard library reference style.
CC and CXX should be set in the environment to help the configure script find the right compiler
AR, RANLIB and STRIP, perhaps READELF should also be set in the environment for library generate.
For python3:*-android, patches should be apply to the setup.py for cross-compiling the standard libraries.
So I have made a draft PR in http://github.com/holmescn/vcpkg on branch fix-android-ndk-r23. But there are some problem that I don't know how to resolve, so I cannot make a PR right now:
- There is an option of ANDROID_API which needed to be appended to the cross-compiling compiler like
armv7a-linux-androideabi${ANDROID_API}-clang. I don't know where to add it.
- The
CMAKE_HOST_SYSTEM_VERSION is empty on macOS which is needed in the --build option like --build=x86_64-apple-darwin${CMAKE_HOST_SYSTEM_VERSION}. Though this could be solved by execute_process of uname -r.
- The
_vcpkg_determine_autotools_host_cpu and _vcpkg_determine_autotools_target_cpu seem not handle Android host and target well. I implement them using MATCHES on VCPKG_DETECTED_CMAKE_SYSTEM_PROCESSOR but it takes more code.
The python patches is another story. I would like to keep track with the problem until the PR is ready to push.
I was trying to embed python into my Android App. So I need to build a bunch of C/C++ libraries besides the
libpython3.x.a. Since Android NDK r21, the GCC toolchain is dropped and only clang as the default compiler. I have written some scripts to build some libraries and a little of patches. But in order to finish the project, I need more C/C++ libraries. So I switch to vcpkg. After some tests, I found that most libraries that are built with CMake seem to work well with the*-androidtriplets contributed by the community, but others that are based on autotools (e.g. configure + make) does not work well. For example, thelibiconvfailed during the config stage due to it is trying to compile with gcc.There are several problems:
VCPKG_DETECTED_CMAKE_CXX_STANDARD_LIBRARIEScontains-static-libc++which will be convert to-l-static-libc++since it is not the standard library reference style.CCandCXXshould be set in the environment to help theconfigurescript find the right compilerAR,RANLIBandSTRIP, perhapsREADELFshould also be set in the environment for library generate.For
python3:*-android, patches should be apply to thesetup.pyfor cross-compiling the standard libraries.So I have made a draft PR in http://github.com/holmescn/vcpkg on branch fix-android-ndk-r23. But there are some problem that I don't know how to resolve, so I cannot make a PR right now:
armv7a-linux-androideabi${ANDROID_API}-clang. I don't know where to add it.CMAKE_HOST_SYSTEM_VERSIONis empty on macOS which is needed in the--buildoption like--build=x86_64-apple-darwin${CMAKE_HOST_SYSTEM_VERSION}. Though this could be solved by execute_process ofuname -r._vcpkg_determine_autotools_host_cpuand_vcpkg_determine_autotools_target_cpuseem not handle Android host and target well. I implement them using MATCHES onVCPKG_DETECTED_CMAKE_SYSTEM_PROCESSORbut it takes more code.The python patches is another story. I would like to keep track with the problem until the PR is ready to push.