g++报错boost问题之generic_category()
2015-08-19 09:25
399 查看
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+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
相关文章推荐
- First Round of Google Phone screen interview backup
- POJ 1042 Gone Fishing
- GoAhead网页提交内容
- django1.8.3搭建博客——1
- Moist (cin,getline的区别)
- uva 11383 Golden Tiger Claw (KM算法)
- google镜像
- HDOJ1709特殊的母函数
- 集训第六周 古典概型 期望 D题 Discovering Gold 期望
- [algorithm] graph algorithm
- UVALive 6129 Sofa, So Good
- UVALive 6124 Hexagon Perplexagon
- django That port is already in use
- category和protocol 第五天稍晚了一些。
- Algorithms—80.Remove Duplicates from Sorted Array II
- AGFA 3rd MUSICA algorithm
- HDU 1036 Average is not Fast Enough!(水题)
- go language
- HDU 1029 Ignatius and the Princess IV
- django session使用方法