步骤:
1. sudo port boost
安装在/ opt / local / boost中的boost文件,库文件位于/ opt / local / lib
中
2.使用XCode创建c ++项目
#include <iostream>
#include <boost/asio.hpp>
int main () {
return 0;
}
3.设置XCode以找出提升
在“构建设置”中 - &gt; “HEADER_SEARCH_PATHS”
在Debug和Release中添加路径/ opt / local / include
4.“构建设置” - &gt; “LIBRARY_SEARCH_PATHS” - &gt;添加/ opt / local / lib以进行调试和发布。
5.构建程序并失败。
错误消息,
Undefined symbols for architecture x86_64:
"boost::system::generic_category()", referenced from:
___cxx_global_var_init1 in main.o
___cxx_global_var_init2 in main.o
"boost::system::system_category()", referenced from:
___cxx_global_var_init3 in main.o
boost::asio::error::get_system_category() in main.o
"boost::asio::error::get_netdb_category()", referenced from:
___cxx_global_var_init5 in main.o <br>
"boost::asio::error::get_addrinfo_category()", referenced from:
___cxx_global_var_init6 in main.o <br>
"boost::asio::error::get_misc_category()", referenced from:
___cxx_global_var_init7 in main.o <br>
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我的程序错了吗?
答案 0 :(得分:8)
你需要链接Boost.System
,/opt/local/lib/libboost_system
应该在{{1}}(带有一些后缀,取决于你如何构建提升)
将其添加到您的Xcode项目中。
答案 1 :(得分:4)
/opt/local/lib
,/usr/local/Cellar/boost
,/usr/local/lib by default
或yourBoostLib/stage/lib