无法使用Xcode成功编译boost
Unable to successfully compile with boost using Xcode
我正在运行OS X 10.11 (El Captain),并试图使用c++和boost编译程序。具体来说,我正在尝试使用boost::program_options
类。以下代码将无法编译:
#include <iostream>
#include <boost/program_options.hpp>
int main(int argc, const char *argv[]) {
boost::program_options::options_description desc("Options");
return 0;
}
并返回错误:
Undefined symbols for architecture x86_64:
"boost::program_options::options_description::m_default_line_length", referenced from:
_main in test.o
processArgs(int, char const**) in test.o
"boost::program_options::options_description::options_description(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned int, unsigned int)", referenced from:
_main in test.o
processArgs(int, char const**) in test.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我有boost 1.58.0安装使用brew, Xcode 7.0.1。我在构建选项下使用默认编译器(Apple LLVM 7.0),并在标题搜索路径中指定/usr/local/Cellar/boost/1.58.0/include
,在库搜索路径中指定/usr/local/Cellar/boost/1.58.0/lib
。此外,我已经检查了目录,以确保正确的文件存在。
任何建议将不胜感激!谢谢,如果还有什么问题,请告诉我。
看起来像是在编译,但不是链接。我相信您需要将libboost_program_options.dylib
添加到您的应用程序的链接二进制库。详情请参阅本页(步骤4)。
我添加库的方式是选择我的目标,然后链接二进制与库,然后选择添加其他。对我来说最困难的部分是导航到/usr/local文件夹(我是Xcode开发的新手)。我的方法是打开Finder,然后选择go -> go to Folder…然后转到/usr/local文件夹,然后从窗口底部拖动到收藏夹。然后,当你在Xcode中单击Add Other时,它就会显示出来,你可以轻松地导航到/usr/local/lib目录并找到boost库。
相关文章:
- VS2017 版本 15.8.3 成功编译内联方法,而不返回所需值
- 如何在 c++ 中导入文件?以及如何成功编译它们?
- 奇怪的语法构造 - 应用于 typedef 的运算符 () 使用 VS2015 成功编译
- "template"关键字限定符是否会导致代码成功编译,但不同?
- 使用不带前缀"std"且不带"using namespace std;"的 std::sort() 成功编译
- 在 C++11 和 C++11 之前成功编译但行为不同的代码示例
- 有没有人在Windows7机器上成功编译过木瓜
- CGAL:如何成功编译和链接CGAL示例(在Mac OS X 10.9 Mavericks上)
- 使用 qmake 成功编译 SSE 指令(但 SSE2 不被识别)
- Socket C++程序在运行时成功编译崩溃
- 在 clang 中显式指定的参数无效,但在 gcc 中成功编译 — 谁错了?
- 为什么这个模板函数能够成功编译
- 无法使用Xcode成功编译boost
- Eclipse可以成功编译,但仍然会出现语义错误
- 成功编译节点模块并"Module did not self-register."
- Eclipse 给出错误"无法解析函数'MessageBoxA'",但仍然成功编译?
- C++ 成功编译,不包含<string>标题
- CGAL4.6 中成功编译的代码的编译错误
- 捕获而不尝试成功编译
- 为什么以下代码在VS2010中成功编译