c++ - 我应该使用 cmake 搜索什么 Boost 包才能包含 Boost Function 的代码?

标签 c++ boost cmake

在我的代码中,我想使用boost::hash<pair<int, int>> ,为此我需要:

#include <boost/functional/hash.hpp>

我使用cmake构建我的项目。我应该使用 find_package 请求什么包裹在CMakeLists.txt ?现在我有:find_package(Boost COMPONENTS program_options regex REQUIRED) 。我没有任何错误,但我怀疑其原因是我安装了所有的 boost 库。

最佳答案

Functional 是仅 header 库,因此您不需要添加任何内容,因为不会链接仅 header 库。请参阅Which boost libraries are header-only?也或者http://www.boost.org/doc/libs/1_53_0/more/getting_started/unix-variants.html#header-only-libraries .

关于c++ - 我应该使用 cmake 搜索什么 Boost 包才能包含 Boost Function 的代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16469823/

相关文章:

c++ - C++ 中的复合 std::istream

python - Boost.Python + OpenGL 段错误

cmake - 如何提前从 cmake 中的函数返回?

c++ - CMake 在 Windows 10 上构建 Tensorflow C++ 错误 : Test COMPILER_OPT_ARCH_NATIVE_SUPPORTED - failed

c++ - 调试错误 R6010 - 已调用 abort()

cmake - 如何告诉 CMake 使用 Windows 路径,而不是 Cygwin 路径?

c++ - 内存操作 malloc 和 free 究竟做了什么?

c++ - 编译带时间符号的移位运算符

c++ - 以可变方式绑定(bind)成员函数

c++ - 如何在C++中将字符转换为字符串?