-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[opencv4:android]: Correct paths in portfile #11269
Conversation
Currently the compilation of opencv4 for android leads to the following folder structure: ```` packages/opencv4_arm_android/ debug/ lib/ sdk/ native/ jni/ include/ opencv2/ share/ README.android ```` vcpkg complains about a missing include folder, and about the presence of unwanted README.android file. **Steps to reproduce the error** ******************************** 1. Install the android triplets: You can copy-paste the script below to populate them (and maybe later adjust them to your needs): ```` echo " set(VCPKG_TARGET_ARCHITECTURE arm) set(VCPKG_CRT_LINKAGE dynamic) set(VCPKG_LIBRARY_LINKAGE dynamic) set(VCPKG_CMAKE_SYSTEM_NAME Android) " > triplets/community/arm-android.cmake echo " set(VCPKG_TARGET_ARCHITECTURE arm64) set(VCPKG_CRT_LINKAGE dynamic) set(VCPKG_LIBRARY_LINKAGE dynamic) set(VCPKG_CMAKE_SYSTEM_NAME Android) " > triplets/community/arm64-android.cmake echo " set(VCPKG_TARGET_ARCHITECTURE x86) set(VCPKG_CRT_LINKAGE dynamic) set(VCPKG_LIBRARY_LINKAGE dynamic) set(VCPKG_CMAKE_SYSTEM_NAME Android) " > triplets/community/x86-android.cmake echo " set(VCPKG_TARGET_ARCHITECTURE x64) set(VCPKG_CRT_LINKAGE dynamic) set(VCPKG_LIBRARY_LINKAGE dynamic) set(VCPKG_CMAKE_SYSTEM_NAME Android) " > triplets/community/x64-android.cmake ```` 2. Install [android ndk](https://developer.android.com/ndk/downloads/) 3. Set ANDROID_NDK_HOME env variable, for example: ```` export ANDROID_NDK_HOME=/home/YourAccount/Android/Sdk/ndk-bundle ```` 4. Try to build opencv4[core]: ```` ./vcpkg install "opencv4[core]:arm-android" ```` You will get the following error ```` -- Installing: .../vcpkg/packages/opencv4_arm-android/share/opencv4/copyright -- Performing post-build validation The folder /include is empty or not present. This indicates the library was not correctly installed. The following files are placed in .../vcpkg/packages/opencv4_arm-android: .../vcpkg/packages/opencv4_arm-android/README.android Files cannot be present in those directories. The following files are placed in .../vcpkg/packages/opencv4_arm-android/debug: .../vcpkg/packages/opencv4_arm-android/debug/README.android Files cannot be present in those directories. Found 3 error(s). Please correct the portfile: ../vcpkg/ports/opencv4/portfile.cmake -- Performing post-build validation done Error: Building package opencv4:android-armeabi-v7a failed with: POST_BUILD_CHECKS_FAILED ```` **What this patch does** ************************ It reorganizes the package folder post install, so that it contents looks like: ```` packages/opencv4_arm-android ├── debug │ ├── lib │ └── sdk │ └── native ├── include │ └── opencv2 │ ├── calib3d │ ├── core │ └── ... ├── lib └── share ├── opencv │ ├── abi-armeabi-v7a │ └── licenses └── opencv4 ```` **How to test this patch** ************************** 1. Build opencv for all 4 archs ```` ./vcpkg install "opencv4[core]:arm-android" "opencv4[core]:arm64-android" "opencv4[core]:x64-android" "opencv4[core]:x86-android" ```` 2. Export opencv4 prefab: ```` ./vcpkg export --triplet x64-android "opencv4[core]" --prefab ```` You will get the following prefab structure ```` prefabo/opencv4 ├── aar │ ├── AndroidManifest.xml │ ├── META-INF │ │ └── LICENSE │ └── prefab │ ├── modules │ │ ├── opencv_calib3d │ │ │ ├── libs │ │ │ │ ├── android.arm64-v8a │ │ │ │ │ ├── abi.json │ │ │ │ │ ├── include │ │ │ │ │ │ └── opencv2 │ │ │ │ │ └── libopencv_calib3d.so │ │ │ │ ├── android.armeabi-v7a │ │ │ │ │ ├── abi.json │ │ │ │ │ ├── include │ │ │ │ │ │ └── opencv2 │ │ │ │ │ └── libopencv_calib3d.so │ │ │ │ ├── android.x86 │ │ │ │ │ ├── abi.json │ │ │ │ │ ├── include │ │ │ │ │ │ └── opencv2 │ │ │ │ │ └── libopencv_calib3d.so │ │ │ │ └── android.x86_64 │ │ │ │ ├── abi.json │ │ │ │ ├── include │ │ │ │ │ └── opencv2 │ │ │ │ └── libopencv_calib3d.so │ │ │ └── module.json │ │ ├── opencv_core │ │ │ ├── libs │ │ │ │ ├── android.arm64-v8a │ │ │ │ │ ├── abi.json │ │ │ │ │ ├── include │ │ │ │ │ │ └── opencv2 │ │ │ │ │ └── libopencv_core.so ````
In general, renaming files after build is the source of many problems when consuming the library in a downstream project Can you please try my pr with opencv 4.3 update, #11130? It might solve the include issue for android toolchain |
Many thanks for this informed answer! Your PR seems to do quite a lot to solve the issue, expect for the remaining README.android files. |
Describe the pull request
This PR handles installation issues for opencv4 under android, by arranging some paths in the package folder.
What does your PR fix? Fixes issue [opencv4:android] build failure (folder /include is empty or not present) #11229
Which triplets are supported/not supported?
Android triplets
Have you updated the CI baseline?
No
Does your PR follow the maintainer guide?
Yes
Additional details
Note: Beware, I am new to the android platform, and I did not succeed in trying out the resulting opencv4 package on an android application ("find_package(OpenCV)" fails).
May be @atkawa7 could help with some instructions on this: below I explain how I can succesfully export a prefab package. My issue is that I do not know how to consume it in an android app
Current status of opencv4 under android
Currently the compilation of opencv4 for android leads to
the following folder structure:
vcpkg complains about a missing include folder, and about the presence
of unwanted README.android file.
Steps to reproduce the error
You can copy-paste the script below to populate them (and maybe later adjust them to your needs):
Install android ndk
Set ANDROID_NDK_HOME env variable, for example:
You will get the following error
What this patch does
It reorganizes the package folder post install, so that it contents looks like:
How to test this patch
You will get the following prefab structure