c++ - 将 Boost 库链接到 Xcode 项目

标签 c++ xcode boost

我正在尝试创建一个使用 Boost 库的项目。我在 OS X 10.9.5(我应该更新它)上使用 Xcode 6.2。我用自制软件 brew install boost 安装了 boost,它位于 /usr/local/Cellar/boost/1.59.0。我将 /usr/local/Cellar/boost/1.59.0/include 路径添加到 Xcode 中的 header 搜索路径,它似乎可以识别它,因为自动完成提示有效。

boost documentation它提到某些 Boost 库必须先构建才能使用。我假设自制软件处理了这一点,因为我在 /usr/local/Cellar/boost/1.59.0/中有一堆 .a.dylib 文件库

我对 C++ 和 Xcode 构建过程还是个新手,但似乎我仍然需要将已编译的库链接到我的项目。我尝试将路径 /usr/local/Cellar/boost/1.59.0/lib 添加到我项目的库搜索路径中,但我不确定这是否正确。

这是我在尝试构建项目时遇到的错误。

Undefined symbols for architecture x86_64:
  "boost::filesystem::detail::create_directory(boost::filesystem::path const&, boost::system::error_code*)", referenced from:
      boost::filesystem::create_directory(boost::filesystem::path const&) in main.o
  "boost::filesystem::detail::status(boost::filesystem::path const&, boost::system::error_code*)", referenced from:
      boost::filesystem::exists(boost::filesystem::path const&) in main.o
  "boost::system::system_category()", referenced from:
      ___cxx_global_var_init2 in main.o
  "boost::system::generic_category()", referenced from:
      ___cxx_global_var_init in main.o
      ___cxx_global_var_init1 in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我还需要配置什么才能让它工作吗?

最佳答案

添加路径是正确的,但你还需要指定你需要的库。在命令行上,您可以在 Xcode 中使用 -l,您可以将它们添加到 Other Linker Flags

您需要的库是 boost_filesystemboost_system

关于c++ - 将 Boost 库链接到 Xcode 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34574173/

相关文章:

ios - restoreCompletedTransactions 并要求登录

c++ - 我可以将 BOOST_FUSION_ADAPT_STRUCT 与继承的东西一起使用吗?

c++ - boost::iterator_adapter 不适用于 STL 算法

C++如何直接访问内存

c++ - 多部分基准的权重是多少?

python - 将 pybind11 绑定(bind)标记为已弃用的最佳方法

c++ - 函数返回的 decltype

ios - Xcode 6.4 "Could not download and install iOS 8.3 simulator"

ios - 'contentStretch' 已弃用 : first deprecated in iOS 6. 0?

c++ - 为什么 boost::any 禁止转发 const&&?