-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
Android build with external libpng is bogus #21507
Copy link
Copy link
Closed
Milestone
Description
System information (version)
- OpenCV => 4.5.3
- Operating System / Platform => Linux
- Compiler => Android NDK r18b
Detailed description
We build the image libraries separately and then pass then on to OpenCV's build. We've encountered a problem on Android though. Because of the way CMake's FindZLIB works, it hardcodes the path to libz.so on Android, which makes the SDK incompatible when moved to a different system. There are workarounds in OpenCV's build, trying to massage the result of FindZLIB, but they work only in the case where all image libraries are built internally.
Steps to reproduce
For Android, we build libpng separately, and then pass it to OpenCV, like so:
cmake \
-D CMAKE_TOOLCHAIN_FILE=${NDK_ROOT}/build/cmake/android.toolchain.cmake \
-D ANDROID_NDK="${NDK_ROOT}" \
-D ANDROID_NATIVE_API_LEVEL=${API_LEVEL} \
-D ANDROID_ABI="${ANDROID_ABI}" \
-D ANDROID_STL="c++_shared" \
-D BUILD_PNG=NO \
-D PNG_PNG_INCLUDE_DIR="${STATIC_INCLUDE_DIR}" \
-D PNG_LIBRARY="-L${STATIC_LIB_DIR}" \
...
(there are a bunch of other parameters to cmake, but the above is the important part)
$STATIC_INCLUDE_DIR + $STATIC_LIB_DIR contain libpng previously built with the Android NDK.
Issue submission checklist
- I report the issue, it's not a question
- I checked the problem with documentation, FAQ, open issues,
forum.opencv.org, Stack Overflow, etc and have not found any solution - I updated to the latest OpenCV version and the issue is still there
- There is reproducer code and related data files: videos, images, onnx, etc
Reactions are currently unavailable