rikyoz / bit7z

A C++ static library offering a clean and simple interface to the 7-zip shared libraries.
https://rikyoz.github.io/bit7z
Mozilla Public License 2.0
602 stars 110 forks source link

CompilerOptions to compile with NDK for Android #157

Closed herm4ns closed 9 months ago

herm4ns commented 11 months ago

I checked the CompilerOptions.cmake and saw that they included options to build the library with GNU or MSVC. I don't know if this is out of scope, but could you update them to be able to compile with NDK for Android?

rikyoz commented 11 months ago

Hi! As far as I know, the Android NDK uses Clang (GCC on older ones, if I remember correctly), which is already supported by bit7z (there are some options in that CompilerOptions.cmake file to make it build with Clang).

I did a couple of tests with the latest NDK, as well as with an older one, and I didn't have any problem compiling the library. The only thing I had to do was to specify the Android toolchain cmake file of the NDK and the ANDROID_PLATFORM variable; also other variables might be needed, like the ANDROID_ABI for targeting arm64.

mkdir build && cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE='/path/to/ndk/build/cmake/android.toolchain.cmake' -DANDROID_PLATFORM=<API level>
cmake --build .

Did you have any issues while compiling bit7z with the NDK? If this is the case, which NDK version are you using?

rikyoz commented 9 months ago

Hi! I recently discovered that bit7z failed to build when compiling using an API level of 23 or earlier. The latest v4.0.2 fixes this issue!