cmake错误:无法找到以下Boost库。

时间:2021-10-24 04:50:33

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

我使用cmake和boost来制作visual studio解决方案。我的命令是:

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.

虽然我已经设置了BOOST_LIBRARYDIR和BOOST_ROOT,但仍然不能找到boost_unit_test_framework。

the directory E:\lib\lib\boost_1_54_0\bin\vc11\lib indeed contains these files:

目录E:\lib\lib\boost _1_ 54_0\bin\vc11\lib确实包含这些文件:

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

但似乎这些都不被认可。是什么问题?Traceback在这里: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

项目在这里:https://github.com/Answeror/yapimpl和https://github.com/Answeror/ACMake希望有人可以尝试cmake yapimpl项目。

2 个解决方案

#1


12  

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开始的,所以看起来您已经构建了boost库的静态版本。boost命名约定:

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.

前缀:除了Microsoft Windows,每个Boost库名称都以这个字符串开始。在Windows上,只有普通的静态库使用lib前缀;导入库和dll没有。

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

在CMake生成的输出中,有一条线表示:

-- [ 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:

此外,您还可以看到CMake正在搜索的库名称不以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 ...):

要告诉CMake搜索Boost的静态版本,只需将Boost_USE_STATIC_LIBS设置为ON。您可以在您的CMakeLists中这样做。在调用find_package之前txt (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

有关FindBoost CMake模块的更多信息,请参阅文档或运行。

cmake --help-module FindBoost

#2


0  

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

我只在使用CMake和boost时设置BOOST_ROOT。其他的工作都没问题。

"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"

#1


12  

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开始的,所以看起来您已经构建了boost库的静态版本。boost命名约定:

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.

前缀:除了Microsoft Windows,每个Boost库名称都以这个字符串开始。在Windows上,只有普通的静态库使用lib前缀;导入库和dll没有。

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

在CMake生成的输出中,有一条线表示:

-- [ 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:

此外,您还可以看到CMake正在搜索的库名称不以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 ...):

要告诉CMake搜索Boost的静态版本,只需将Boost_USE_STATIC_LIBS设置为ON。您可以在您的CMakeLists中这样做。在调用find_package之前txt (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

有关FindBoost CMake模块的更多信息,请参阅文档或运行。

cmake --help-module FindBoost

#2


0  

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

我只在使用CMake和boost时设置BOOST_ROOT。其他的工作都没问题。

"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"