记boost在gcc的一个库链接问题generic_category()
2013-08-01 23:30
405 查看
报错大致如下:
main.cpp:(.text+0x49): undefined reference to `boost::system::generic_category()'
main.cpp:(.text+0x53): undefined reference to `boost::system::generic_category()'
main.cpp:(.text+0x5d): undefined reference to `boost::system::system_category()'
当时搞了很久,各种库各种一通链接,始终没解决问题
解决方案:
"boost/filesystem.hpp" 这个文件依赖于boost_system,编译的时候,需要 -lboost_system选项,但是你的编译选项里头已经指定该选项,为什么还会出现链接错误呢。我也纳闷了半天,后来发现,原来是-l选项的顺序问题。在g++的man帮助信息里面,我发现了下面的话:
引用
It makes a difference where in the command you write this option; the linker searches and processes libraries and object files in the order they are specified. Thus, foo.o -lz bar.o searches library z after file foo.o but before bar.o. If bar.o
refers to functions in z, those functions may not be loaded.读完这段话,应该就明白出错原因了。所以,解决方案就是用下面的命令来编译:
引用g++ main.cpp -lboost_system -lboost_filesystem
main.cpp:(.text+0x49): undefined reference to `boost::system::generic_category()'
main.cpp:(.text+0x53): undefined reference to `boost::system::generic_category()'
main.cpp:(.text+0x5d): undefined reference to `boost::system::system_category()'
当时搞了很久,各种库各种一通链接,始终没解决问题
解决方案:
"boost/filesystem.hpp" 这个文件依赖于boost_system,编译的时候,需要 -lboost_system选项,但是你的编译选项里头已经指定该选项,为什么还会出现链接错误呢。我也纳闷了半天,后来发现,原来是-l选项的顺序问题。在g++的man帮助信息里面,我发现了下面的话:
引用
It makes a difference where in the command you write this option; the linker searches and processes libraries and object files in the order they are specified. Thus, foo.o -lz bar.o searches library z after file foo.o but before bar.o. If bar.o
refers to functions in z, those functions may not be loaded.读完这段话,应该就明白出错原因了。所以,解决方案就是用下面的命令来编译:
引用g++ main.cpp -lboost_system -lboost_filesystem
相关文章推荐
- 记boost在gcc的一个库链接问题generic_category()
- 使用boost的库链接问题generic_category()
- boost中g++ 链接undefined reference to `boost::system::generic_category()问题
- g++报错boost问题之generic_category()
- g++报错boost问题之generic_category()
- undefined reference to `boost::system::generic_category()问题
- boost编译的一个bug:undefined reference to `boost::system::generic_category()'
- gcc/g++ 动态编译和链接问题
- ?C++编译链接时的一个小问题
- Generic Host Process for Win32 Services 遇到了一个问题,需要关闭
- gcc 链接库的顺序问题
- gcc 编译relocation相关的一个问题
- 编译与链接的问题 gcc -fPIC -shared
- VC运行库版本不同导致链接.LIB静态库时发生重复定义问题的一个案例分析和总结
- 一个GCC4.6.3的奇妙问题的糊涂解决方案
- Generic Host Process for Win32 Services 遇到了一个问题,需要关闭
- 总结一个yum链接不上任何源的问题-----架设本地yum服务器centos5
- JqueryMobile链接一个页面,而链接页面中图片需刷新才显示的问题
- VC运行库版本不同导致链接.LIB静态库时发生重复定义问题的一个案例分析和总结
- [008]C---gcc环境下的一个编译器版本问题