我正在尝试创建一个使用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中的标题搜索路径中,它似乎认出了它,因为自动完成提示有效。
在boost documentation中,它提到必须先构建一些Boost库才能使用它们。我认为自制软件可以解决这个问题,因为我在.a
.dylib
和/usr/local/Cellar/boost/1.59.0/lib
个文件
我还是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)
我需要配置一些其他东西才能让它发挥作用吗?
答案 0 :(得分:3)
添加路径是正确的,但您还需要指定所需的库。在命令行上,您可以在Xcode中使用-l,将它们添加到Other Linker Flags
。
您需要的库是boost_filesystem
和boost_system
。