【发布时间】:2020-10-01 18:41:37
【问题描述】:
我正在尝试在自定义目录中安装 boost。我做到了:
cd boost_dir
./bootstrap.sh --prefix=/custom_dir
./b2
现在我想做的是告诉 CMake 指向那个库。为此,我补充说:
set(BOOST_ROOT "/custom_dir")
FIND_PACKAGE(Boost COMPONENTS program_options REQUIRED)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(myProject ${Boost_LIBRARIES})
CMake 显然在该目录中找到了提升:
cmake .
-- Found Boost: /custom_dir (found suitable version "1.66.0", minimum required is "1.66") found components: program_options -- Configuring done
-- Generating done
-- Build files have been written to: /my_project
但是,在编译时,我仍然得到:
undefined reference to `boost::program_options::options_description::options_description(std::string const&, unsigned int, unsigned int)'
一些答案指出,boost 必须使用与我正在使用的程序相同的编译器进行编译。但是,我不确定我上面所做的步骤是否真的编译了 boost 或只是复制了未压缩的库?
另外,它是否使用了路径解析的 g++ 或系统默认 /usr/bin 中的东西?原因是我没有 root 访问权限,并且还在自定义目录中安装了更新的 GCC。我已将我的 PATH 指向更新后的 g++。
【问题讨论】: