Open didi16 opened 6 years ago
As you see before I tried to ping some people that have used OpenMVG on android app before (#1326) but they did not provided any answer.
See here the thread of people that succeeded to use OpenMVG on iPhone
Personally i would've helped happily (within my abilities) if the author of #1326 had any specific questions i could answer.
Nevertheless, cross-compiling is not an Android specific issue, albeit it certainly makes it a bit more tricky. OpenMVG is cmake-based, that makes the whole process much less stressful.
For quite a long time, libraries had to adopt (and still do) a certain habit of providing a cmake toolchain descriptor designed specifically for android builds, having all the variables necessary for cmake to build Android binaries. You had to specify that as a cmake parameter: cmake -DCMAKE_TOOLCHAIN_FILE=<file>
. This was a necessity because cmake had no knowledge of Android as a system and the different build tools it has, so you had to tell all the directives through these descriptor files.
Fortunately, it seems the guys at Kitware began to notice the ever-growing need for cmake projects to run on Android, so they decided to do the heavy lifting themselves by dealing with all the variables natively, without the need of such descriptor files. Now cmake knows what Android is when you desire to build for it, and you only need to provide the variables specific to your needs. You can read more about it here
TL;DR: The way you build for Android is the same you build for Linux. The only difference is the parameters you provide. The aformentioned link even has a cmake invocation example if you just want to experiment with it. Let me know if you hit any issues.
Hi,
I managed to cross-compile everything, including software, using Oliver001/openMVG rep. In the end it is quite simple, despite the fact that documentation might not be that clear all the time.
Thanks
Glad it worked out!
@didi16 Would you like to help to upgrade the documentation with an Android section?
Thx @didi16 and @donlk for your messages.
@pmoulon Yes, I would be quite glad to contribute!
@didi16 I would be happy to work with you on extending the documentation toward adding an Android section. Feel free to ping me.
@pmoulon @didi16 @donlk Hi all, good day, Im facing problem of the integration of openMVG with android studio, can you guys help me in solve this problem? Thanks.
What problem are you facing? please elaborate so we can help you.
@pmoulon my problem is how can i integrate openMVG in android studio? Can you provide me some step to doing so? thanks
Hi. I couldnt configure/build openMVG. and im losing ideas. i tried to cross compile openMVG in cmake(gui) choosing ninja as generator and choosing "specify toolchain file for cross-compiling" using this path Android/Sdk/ndk/22.1.7171670/build/cmake/android.toolchain.cmake and this happened "Configuring incomplete, errors occurred!" im using though Oliver001/openMVG. what is wrong with it?
Any other informative error message? @philopkid
When i put the folder openMVG in the ndk folder and uses the toolchain on the cmake(gui) Android/Sdk/ndk/22.1.7171670/build/cmake/android.toolchain.cmake it started to configure but then. when i generate the folder where there should have been an output it is empty? what is wrong with it? @pmoulon
This what happens when i configure. The problem now it isnt generating anything when i hit generate. Note: I made one changes. I changed the find_host_package() with find_package() coz it seems that find_host_packages gets an error of unknown command. when i use ninja and android.toolchain.cmake
ANDROID_PLATFORM not set. Defaulting to minimum supported version
16.
Android: Targeting API '30' with architecture 'arm', ABI 'armeabi-v7a', and processor 'armv7-a'
Android: Selected unified Clang toolchain
The C compiler identification is Clang 11.0.5
The CXX compiler identification is Clang 11.0.5
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working C compiler: C:/android-ndk-r22b/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe - skipped
Detecting C compile features
Detecting C compile features - done
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Check for working CXX compiler: C:/android-ndk-r22b/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe - skipped
Detecting CXX compile features
Detecting CXX compile features - done
Hello from Android build!
Checking for C++11 compiler
Checking for C++11 compiler - available
Performing Test SUPPORTS_STD_CXX11
Performing Test SUPPORTS_STD_CXX11 - Success
Performing Test SUPPORTS_STD_CXX01
Performing Test SUPPORTS_STD_CXX01 - Success
Looking for C++ include thread
Looking for C++ include thread - found
Looking for C++ include chrono
Looking for C++ include chrono - found
Found OpenMP_C: -fopenmp=libomp (found version "5.0")
Found OpenMP_CXX: -fopenmp=libomp (found version "5.0")
Found OpenMP: TRUE (found version "5.0")
-- Did not find MOSEK header
-- Did not find MOSEK library
Could not find mosek library on this machine.
Eigen 3.2.8 found (include: C:/android-ndk-r22b/openMVGo/src/third_party/eigen)
Flann 1.8.4 found (include: C:/android-ndk-r22b/openMVGo/src/third_party/flann/src/cpp/flann)
CoinUtils 2.9.3 found (include: C:/android-ndk-r22b/openMVGo/src/dependencies/osi_clp/CoinUtils/src)
Clp 1.15.11 found (include: C:/android-ndk-r22b/openMVGo/src/dependencies/osi_clp/Clp/src)
Osi 0.106.10 found (include: C:/android-ndk-r22b/openMVGo/src/dependencies/osi_clp/Osi/src/Osi)
CMake Deprecation Warning at dependencies/osi_clp/CMakeLists.txt:6 (CMAKE_MINIMUM_REQUIRED):
Compatibility with CMake < 2.8.12 will be removed from a future version of
CMake.
Update the VERSION argument
Lemon found (include: C:/android-ndk-r22b/openMVGo/src/third_party/lemon/lemon) CMake Deprecation Warning at third_party/lemon/CMakeLists.txt:1 (CMAKE_MINIMUM_REQUIRED): Compatibility with CMake < 2.8.12 will be removed from a future version of CMake.
Update the VERSION argument
Found PythonInterp: C:/Users/Sky/AppData/Local/Programs/Python/Python39/python.exe (found version "3.9.6")
Could NOT find Wget (missing: WGET_EXECUTABLE)
Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
Could NOT find Ghostscript (missing: GHOSTSCRIPT_EXECUTABLE)
Could NOT find GLPK (missing: GLPK_LIBRARY GLPK_INCLUDE_DIR GLPK_PROPER_VERSION_FOUND) (Required is at least version "4.33")
Could NOT find ILOG (missing: ILOG_CPLEX_LIBRARY ILOG_CPLEX_INCLUDE_DIR)
Could NOT find COIN (missing: COIN_INCLUDE_DIR COIN_CBC_LIBRARY COIN_CBC_SOLVER_LIBRARY COIN_CGL_LIBRARY COIN_CLP_LIBRARY COIN_COIN_UTILS_LIBRARY COIN_OSI_LIBRARY COIN_OSI_CBC_LIBRARY COIN_OSI_CLP_LIBRARY)
Could NOT find SOPLEX (missing: SOPLEX_LIBRARY SOPLEX_INCLUDE_DIR)
Looking for sys/types.h
Looking for sys/types.h - found
Looking for stdint.h
Looking for stdint.h - found
Looking for stddef.h
Looking for stddef.h - found
Check size of long long
Check size of long long - done
Looking for pthread.h
Looking for pthread.h - found
Performing Test CMAKE_HAVE_LIBC_PTHREAD
Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
Looking for pthread_create in pthreads
Looking for pthread_create in pthreads - not found
Looking for pthread_create in pthread
Looking for pthread_create in pthread - not found
Check if compiler accepts -pthread
Check if compiler accepts -pthread - yes
Found Threads: TRUE
CMake Deprecation Warning at third_party/jpeg/CMakeLists.txt:2 (cmake_minimum_required):
Compatibility with CMake < 2.8.12 will be removed from a future version of
CMake.
Update the VERSION argument
Looking for stdlib.h Looking for stdlib.h - found CMake Deprecation Warning at third_party/png/CMakeLists.txt:9 (cmake_minimum_required): Compatibility with CMake < 2.8.12 will be removed from a future version of CMake.
Update the VERSION argument
Looking for assert.h Looking for assert.h - found Looking for fcntl.h Looking for fcntl.h - found Looking for io.h Looking for io.h - not found Looking for jbg_newlen Looking for jbg_newlen - not found Looking for mmap Looking for mmap - found Looking for search.h Looking for search.h - found Looking for string.h Looking for string.h - found Looking for unistd.h Looking for unistd.h - found CMake Deprecation Warning at third_party/vectorGraphics/CMakeLists.txt:1 (CMAKE_MINIMUM_REQUIRED): Compatibility with CMake < 2.8.12 will be removed from a future version of CMake.
Update the VERSION argument
CMake Deprecation Warning at third_party/cxsparse/CMakeLists.txt:4 (CMAKE_MINIMUM_REQUIRED): Compatibility with CMake < 2.8.12 will be removed from a future version of CMake.
Update the VERSION argument
CMake Deprecation Warning at third_party/ceres-solver/CMakeLists.txt:32 (cmake_minimum_required): Compatibility with CMake < 2.8.12 will be removed from a future version of CMake.
Update the VERSION argument
CMake Deprecation Warning at third_party/ceres-solver/CMakeLists.txt:33 (cmake_policy): Compatibility with CMake < 2.8.12 will be removed from a future version of CMake.
Update the VERSION argument
CMake Warning (dev) at third_party/ceres-solver/CMakeLists.txt:115 (option): Policy CMP0077 is not set: option() honors normal variables. Run "cmake --help-policy CMP0077" for policy details. Use the cmake_policy command to set the policy and suppress this warning.
For compatibility with older versions of CMake, option is clearing the normal variable 'BUILD_SHARED_LIBS'. This warning is for project developers. Use -Wno-dev to suppress it.
Eigen 3.2.8 found (include: C:/android-ndk-r22b/openMVGo/src/third_party/eigen) -- Found Eigen version 3.2.8: C:/android-ndk-r22b/openMVGo/src/third_party/eigen
Found OpenMP_C: -fopenmp=libomp (found version "5.0") Found OpenMP_CXX: -fopenmp=libomp (found version "5.0") CMake Deprecation Warning at third_party/easyexif/CMakeLists.txt:3 (CMAKE_MINIMUM_REQUIRED): Compatibility with CMake < 2.8.12 will be removed from a future version of CMake.
Update the VERSION argument
CMake Deprecation Warning at third_party/eigen/CMakeLists.txt:2 (cmake_minimum_required): Compatibility with CMake < 2.8.12 will be removed from a future version of CMake.
Update the VERSION argument
Configured Eigen 3.2.8
Could NOT find Sphinx (missing: SPHINX_EXECUTABLE) Sphinx need to be installed to generate the sphinx documentation Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) Doxygen need to be installed to generate the doxygen documentation
OpenMVG version: 1.0.0 Build Shared libs: OFF Build OpenMVG tests: OFF Build OpenMVG documentation: ON Build OpenMVG samples applications: OFF Build OpenMVG openGL examples: OFF Enable code coverage generation: OFF Enable OpenMP parallelization: ON Build OpenCV+OpenMVG samples programs: OFF Use OpenCV SIFT features: OFF
EIGEN: 3.2.8 (internal) CERES: 1.11.0 (internal) FLANN: 1.8.4 (internal) LIBTIFF: (internal) LIBPNG: (internal) LIBJPEG (internal) CLP: 1.15.11 (internal) COINUTILS: 2.9.3 (internal) OSI: 0.106.10 (internal) LEMON: 1.3 (internal)
Configuring done
I solved it. didi6 was right when he said this "In the end it is quite simple, despite the fact that documentation might not be that clear all the time.".
@philopkid What did you do?!
Please help me. I am not sure what exactly should I do to import this library to an Android project. I was fine when I generated project for VS. With some search I realized that I should copy src
directory content into a directory in my Android project that I marked it as cmake directory in gradle.build
. When I tried to build project I goth this error:
C/C++: C:\Users\PCMD\AndroidStudioProjects\Trowel\app\src\main\cpp\CMakeLists.txt debug|x86 : CMake Error at C:\Users\PCMD\AndroidStudioProjects\Trowel\app\src\main\cpp\cmakeFindModules\FindEigen.cmake:53 (MESSAGE): You are attempting to build without Eigen. Please use cmake variable -DEIGEN_INCLUDE_DIR_HINTS:STRING="PATH" or EIGEN_INCLUDE_DIR_HINTS env. variable to a valid Eigen path. Or install last Eigen version. Call Stack (most recent call first): CMakeLists.txt:257 (find_package)
I did what it says and there was no progress. Then I decided to do it with Cmake GUI based on what @pmoulon said assuming this is the correct way to do it (And I'm still not sure what result should I expect and what is the next step...). It gave me some error that said 'CMAKE_MAKE_PROGRAM not specified' or something like that. Then I downloaded Ninja build and specified the variable in Cmake and then back to previous step. It gave me the one Android Studio was giving me about Eigen library... .
Please help me. This is very time sensitive for me. Thank you.
Any help?
@MohammadMDSA look for cmake module path on android toolchain
@philopkid I actually solved it and it was much more complicated. I will write a complete step-by-step solution after finishing my project.
Thank you guys for helping each other. Appreciated this. @MohammadMDSA Feel free to add a section in the build.MD or consider add something in the wiki section.
I wish it would be easy for all platform...
@MohammadMDSA I'm trying to build on Android as well, can't quite get it working. Do you have any hints about how you got it working before I have to work out everything you've done on my own? Cheers for any help!
Hi everyone,
For my project I need to implement part of the functions available on openMVG on android. My goal is to cross compile the whole library to android using standalone Toolchains. I've read through some of the issues and I am aware that there is already a rep for this purpose. However, i've found it very frustrating to actually make it work and documentation is a bit scarce. I have little experience with cross compilation and after 3 days trying to cross compile i haven't succeed yet. Is there anyone familiar with this project that knows how to do this? I feel that my lack of experience is really delaying me while this should not take all this time.