zhangxaochen
zhangxaochen

Reputation: 34047

cmake error: The following Boost libraries could not be found

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

Upvotes: 5

Views: 17243

Answers (2)

Vertexwahn
Vertexwahn

Reputation: 8170

I only set BOOST_ROOT when using CMake and boost. Everything else works without any 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"

Upvotes: 0

Fraser
Fraser

Reputation: 78488

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

Upvotes: 14

Related Questions