Cmake error: Could not find the following Boost libraries

I use cmake and boost to make a visual studio solution. my team:

 F:\C++\yapimpl\build>cmake .. -G"Visual Studio 11" -DBOOST_ROOT=E:\lib\lib\boost _1_54_0 -DBOOST_LIBRARYDIR=E:\lib\lib\boost_1_54_0\bin\vc11\lib 

although I set BOOST_LIBRARYDIR and BOOST_ROOT , it still says boost_unit_test_framework not found.

the E:\lib\lib\boost_1_54_0\bin\vc11\lib really contains these files:

 08/08/2013 CSer 03:48 12,738,344 libboost_unit_test_framework-vc110-mt-1 _54.lib 08/08/2013 CSer 03:44 31,489,264 libboost_unit_test_framework-vc110-mt-g d-1_54.lib 08/08/2013 CSer 04:10 14,109,766 libboost_unit_test_framework-vc110-mt-s -1_54.lib 08/08/2013 CSer 03:59 32,856,094 libboost_unit_test_framework-vc110-mt-s gd-1_54.lib 

but it seems they are not recognized. what is the problem? Traceback is here: http://codepad.org/zgL9tpjo

the project is here: https://github.com/Answeror/yapimpl as well as https://github.com/Answeror/ACMake hope someone can try the cmake yapimpl project

+4
source share
2 answers

Since your library names start with lib , it looks like you created static versions of boost libraries. format naming conventions :

lib

Prefix: In addition to Microsoft Windows, each Boost library name starts on this line. On Windows, only regular static libraries use the lib prefix; import libraries and DLLs do not work.

The output generated by CMake has a line that reads:

 -- [ F:/C++/yapimpl/acmake/FindBoost.cmake:570 ] Boost_USE_STATIC_LIBS = OFF 

In addition, you can see that the library names that CMake is looking for do not start with lib :

 ... Searching for UNIT_TEST_FRAMEWORK_LIBRARY_RELEASE: boost_unit_test_framework-vc110-mt-1_54;... 

To tell CMake to look for a static version of Boost, you just need to set Boost_USE_STATIC_LIBS to ON . You can do this in your CMakeLists.txt before calling find_package(Boost ...) :

 set(Boost_USE_STATIC_LIBS ON) 

or you can just install it on the command line:

 cmake . -DBoost_USE_STATIC_LIBS=ON 

For more information about the CMake FindBoost module, see > docs , or run

 cmake --help-module FindBoost 
+12
source

I set BOOST_ROOT when using CMake and boost. Everything else works without problems.

 "C:\Program Files (x86)\CMake 2.8\bin\cmake" -G"Visual Studio 11 Win64" -HC:\USB\dev\MyProject -BC:\build\MyProject -DBOOST_ROOT="C:\USB\thirdparty\vs2012\boost_1_54_0-x64" 
0
source

Source: https://habr.com/ru/post/1500234/


All Articles