步骤:
1.sudo port boost
安装在/ opt/local/boost中的boost文件,库文件在/ opt/local/lib中
2.使用XCode创建c ++项目
#include <iostream>
#include <boost/asio.hpp>
int main () {
return 0;
}
Run Code Online (Sandbox Code Playgroud)
3.设置XCode以
在"构建设置" - >"HEADER_SEARCH_PATHS"
中找到提升,在Debug和Release中添加路径/ opt/local/include
4."Build Settings" - >"LIBRARY_SEARCH_PATHS" - > add/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)
Run Code Online (Sandbox Code Playgroud)
我的程序错了吗?
你需要链接Boost.System,它应该在/opt/local/lib/libboost_system(带有一些后缀,取决于你如何构建boost)
将其添加到您的Xcode项目中.
| 归档时间: |
|
| 查看次数: |
6329 次 |
| 最近记录: |