Issue
For my Android application, I want to port a C++ code which needs libtiff.
I have downloaded sources of libtiff and I try to compile them to generate libtiff.so in different architectures :
- arm64-v8a
- armeabi-v7a
- x86
- x86_64
But all I have succeeded in is to generate a libtiff.dylib...
What can I do to generate .so instead of .dylib in the 4 previous architecture ?
Here are my command lines :
> cd libtiff
> mkdir install
> cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=install --enable-shared .
> make
> make install
Note: I'm on Mac and compilation stuff is not my favorite subject ^^
Solution
I've found a way to cross-compile this lib with Android tools.
Here are the command lines to generate, for example, the arm64-v8a version
> [CMAKE_BIN_PATH]/cmake -DANDROID_ABI=arm64-v8a -DCMAKE_BUILD_TYPE=Release -DANDROID_PLATFORM=android-21 -DANDROID_NDK=[NDK_PATH] -DCMAKE_INSTALL_PREFIX=install -DCMAKE_TOOLCHAIN_FILE=[NDK_PATH]/build/cmake/android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=[CMAKE_BIN_PATH]/ninja -G Ninja
> [CMAKE_BIN_PATH]/ninja
> [CMAKE_BIN_PATH]/ninja install
or, in a one-line version
> [CMAKE_BIN_PATH]/cmake -DANDROID_ABI=arm64-v8a -DCMAKE_BUILD_TYPE=Release -DANDROID_PLATFORM=android-21 -DANDROID_NDK=[NDK_PATH] -DCMAKE_INSTALL_PREFIX=install -DCMAKE_TOOLCHAIN_FILE=[NDK_PATH]/build/cmake/android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=[CMAKE_BIN_PATH]/ninja -G Ninja && [CMAKE_BIN_PATH]/ninja && [CMAKE_BIN_PATH]/ninja install
In details:
- [CMAKE_BIN_PATH] is the path of cmake: /Library/Android/sdk/cmake/3.6.4111459/bin
- [NDK_PATH] is the path of the NDK: /Library/Android/sdk/ndk-bundle
- CMAKE_INSTALL_PREFIX is a flag to specify the install dir. In my case, I've decided to create the install dir in the libtiff dir
- CMAKE_TOOLCHAIN_FILE: if a flag to specify the toolchain to use. Use the Android toolchain file inside the NDK dir, and not in the cmake dir
- CMAKE_MAKE_PROGRAM is a flag to specify the path of ninja, located in the cmake dir
- -G is the specify the build system generator, Ninja here
Answered By - Bruno
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.