步骤:
1. sudo port boost
boost文件安装在/opt/local/boost,库文件在/opt/local/lib
2. 使用XCode创建c++工程
#include <iostream>
#include <boost/asio.hpp>
int main () {
return 0;
}
3.设置XCode以
在Debug和Release
中的“Build Settings”->“HEADER_SEARCH_PATHS”中找到boost添加路径/opt/local/include
4.“Build Settings”->“LIBRARY_SEARCH_PATHS”->添加/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)
我在程序上错了吗?