最近我开始使用Windows上的Boost进行项目工作。它需要是跨平台的,所以我也在Mac上安装了它。不幸;每当我将它添加到Xcode项目时,它都会给我带来大量的链接错误和转换警告。Mac上的Boost链接器错误(OSX 10.10.02 | Xcode 6.1.1)
实例链接器错误之一:
Undefined symbols for architecture x86_64:
"boost::system::system_category()", referenced from: ___cxx_global_var_init2 in main.o boost::asio::error::get_system_category() in main.o boost::system::error_code::error_code() 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)
转换的警告的一个实例:
In file included from /usr/local/Cellar/boost/1.57.0/include/boost/date_time/posix_time/posix_time_types.hpp:16: /usr/local/Cellar/boost/1.57.0/include/boost/date_time/posix_time/posix_time_duration.hpp:24:21: warning: implicit conversion loses integer precision: 'long' to 'hour_type' (aka 'int') [-Wshorten-64-to-32] time_duration(h,0,0)
我试了好几种安装方法和配置方法,但它仍然不会工作。
这是我的步骤:
- 编译升压或升压得到的编译版本。
- 创建一个XCode项目。
- 在主类中输入this示例代码。
- 将标题和库路径添加到Xcode项目文件。
- 构建。
编译选项我曾尝试:
- 从源代码使用the official guide编译。
- 使用几个脚本从源代码编译我在这里找到了Stackoverflow。
- 安装brew包管理器并下载带有二进制文件的包。
配置选项我曾尝试:
- 设置为/usr/local/Cellar/boost/1.57.0/include或等同物和 的报头搜索路径设定库搜索路径到/ usr /local/Cellar/boost/1.57.0/lib或等价物。
- 只设置标题搜索路径而不设置库路径。
- 选项1但递归(导致更多错误)。
如果有人能指出我正确的方向,我将非常感激。我认为这是与Xcode相关的,因为所有的编译版本都给我提供了相同的错误。