Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cmake error: The following Boost libraries could not be found

Tags:

c++

boost

cmake

I'm using cmake and boost to make visual studio solution. my command is:

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

though I've set BOOST_LIBRARYDIR and BOOST_ROOT, it still says boost_unit_test_framework could not be found.

the directory E:\lib\lib\boost_1_54_0\bin\vc11\lib indeed 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 seems those are not recognized. what's the problem? the Traceback is here: http://codepad.org/zgL9tpjo

the project is here : https://github.com/Answeror/yapimpl and https://github.com/Answeror/ACMake hope someone could try cmake the yapimpl project

like image 571
zhangxaochen Avatar asked Sep 03 '13 03:09

zhangxaochen


1 Answers

As your library names all start with lib, it seems like you have built static versions of the boost libraries. The boost naming conventions state:

lib

      Prefix: except on Microsoft Windows, every Boost library name begins with this string. On Windows, only ordinary static libraries use the lib prefix; import libraries and DLLs do not.

In the output generated by CMake, there is a line which states:

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

Also, you can see that the library names CMake is searching for don't start with lib:

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

To tell CMake to search for the 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 set it on the command line:

cmake . -DBoost_USE_STATIC_LIBS=ON

For more info on the FindBoost CMake module, see the docs, or run

cmake --help-module FindBoost
like image 134
Fraser Avatar answered Sep 20 '22 06:09

Fraser