Possible causes for Boost not being found by CMake in certain situations?
When cross-compiling, the toolchain file normally sets the variable CMAKE_FIND_ROOT_PATH. Combined with the CMAKE_FIND_ROOT_PATH_MODE_LIBRARY variable set to ONLY
, CMAKE_FIND_ROOT_PATH
variable is used as effective chroot for find_library
calls, so only libraries under the given prefix(es) are searched.
Analogue variables exist to adjust the behavior for find_path
(used for searching include paths) and find_program
.
THe toolchain file you use actually sets CMAKE_FIND_ROOT_PATH
at line 1521:
set( CMAKE_FIND_ROOT_PATH "${ANDROID_TOOLCHAIN_ROOT}/bin"
"${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}"
"${ANDROID_SYSROOT}"
"${CMAKE_INSTALL_PREFIX}"
"${CMAKE_INSTALL_PREFIX}/share" )
and below sets CMAKE_FIND_ROOT_PATH_MODE_*
variables to ONLY
. So you need to have Boost installed under one of these directories, and give hints (like BOOST_ROOT) relative to it.
Note, that Boost should be built for the target platform (Android NDK in you case), not for the platform where you cross-compile (Linux).
Cmake error: Could NOT find Boost (missing: Boost_INCLUDE_DIR)
I solved this by adding sentence set(BOOST_ROOT C:/local/boost_1_71_0)
before find_package(Boost REQUIRED)
LOL...
But I still wonder why I need to add this.
CMake is not finding Boost
Your output shows that CMake is searching for the libraries in the following places:
D:/program files/boost_1_51/bin/lib
D:/program files/boost_1_51/bin/stage/lib
D:/program files/boost_1_51/lib
D:/program files/boost_1_51/../lib
D:/program files/boost_1_51/stage/lib
C:/boost/lib
C:/boost
C:\Program Files (x86)/boost/boost_1_51_0/lib
C:\Program Files (x86)/boost/boost_1_51/lib
C:\Program Files (x86)/boost/lib
C:\Program Files (x86)/boost
/sw/local/lib
It also shows that it's expecting the libraries to be named in a certain way. For example, the release version of Boost.Thread:
boost_thread-vc100-mt-1_51
boost_thread-vc100-mt
boost_thread-mt-1_51
boost_thread-mt
boost_thread
If your Boost libraries do exist in one of the searched locations, then it's probably the name of the library that's the problem. You can adjust the expected name of the Boost libraries by setting the appropriate CMake variables relevant to the FindBoost module.
For example, if you built Boost using bjam with link=static threading=multi
then in your CMakeLists.txt before find_package(Boost ...)
you'll want to do
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
Or invoke CMake with -DBoost_USE_STATIC_LIBS=ON -DBoost_USE_MULTITHREADED=ON
.
As @noam has pointed out in the comments below, in this particular case, it appears that CGAL requires the shared (DLL) versions of the Boost libraries; passing -DBoost_USE_STATIC_LIBS=ON
on the command line doesn't have any effect.
Related Topics
Why Does This If Condition Fail for Comparison of Negative and Positive Integers
Member Access into Incomplete Type Error
Static Control Background Color with C++
Is There a Functional Difference Between "2.00" and "2.00F"
Most Terse and Reusable Way of Wrapping Template or Overloaded Functions in Function Objects
Is-Braces-Constructible Type Trait
Order of Evaluation of Function Parameters
What Operators Do I Have to Overload to See All Operations When Passing an Object to a Function
Problems with Move Constructor and Move Overloaded Assignment Operator
Differencebetween Cout, Cerr, Clog of iOStream Header in C++? When to Use Which One
I Want to Generate the Nth Term of the Sequence 1,3,8,22,60 ,164 in Order(1) or Order of (Nlogn)
Load Image with Opencv Mat C++
Why Is Std::Iterator Deprecated