G ++无法找到boost库 [英] G++ cannot find boost library

查看:597
本文介绍了G ++无法找到boost库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在命令行编译并不好。我的问题是无法编译简单的项目,从升压依赖。以下是日志我尝试:

  $ G ++ -Wall -o TEST.CPP主
/tmp/ccCTvBYE.o:在功能`__static_initialization_and_destruction_0(INT,INT):
。TEST.CPP :(文字+ 0x6b):未定义的引用`的boost ::系统:: generic_category()
。TEST.CPP :(文字+ 0x77):未定义的引用`的boost ::系统:: generic_category()
。TEST.CPP :(文字+ 0X83):未定义的引用`的boost ::系统:: system_category()
/tmp/ccCTvBYE.o:在功能`提高:: ASIO ::错误:: get_system_category():
test.cpp:(.text._ZN5boost4asio5error19get_system_categoryEv[_ZN5boost4asio5error19get_system_categoryEv]+0x5):未定义的引用`的boost ::系统:: system_category()
collect2:错误:LD返回1退出状态

因此​​,<一个href=\"http://stackoverflow.com/questions/13467072/c-boost-undefined-reference-to-boostsystemgeneric-category\">there我发现说明添加 -lboost_system -lboost_system-MT 。我得到了以下内容:

  $ G ++ -lboost_system -Wall -o TEST.CPP主
在/ usr /斌/劳工处:找不到-lboost_system
collect2:错误:LD返回1退出状态$ G ++ -lboost_system-MT -Wall -o TEST.CPP主
在/ usr /斌/劳工处:找不到-lboost_system-MT
collect2:错误:LD返回1退出状态

我试图找到 boost_system 库。

  $ / sbin目录/ -p LDCONFIG | grep的boost_system
    libboost_system.so.1.53.0(libc6的,X86-64)=&GT; /usr/lib/x86_64-linux-gnu/libboost_system.so.1.53.0

然后我不成功尝试了以下

  $ G ++ -I的/ home / THIRD_PARTY /升压/-L/ usr / lib目录/ x86_64的-Linux的GNU /-lboost_system -Wall -o TEST.CPP主
在/ usr /斌/劳工处:找不到-lboost_system
collect2:错误:LD返回1退出状态

现在我卡住了。如何形成命令编译?

修改

下面的努力并没有帮助了。

  LN -s /usr/lib/x86_64-linux-gnu/libboost_system.so.1.53.0 /usr/lib/x86_64-linux-gnu/libboost_system.so
-n LDCONFIG / usr / lib目录/ x86_64的-Linux的GNU /$ LL / usr / lib目录/ x86_64的-Linux的GNU / | grep的boost_system
lrwxrwxrwx 1根根51янв。 21 19:47 libboost_system.so - &GT; /usr/lib/x86_64-linux-gnu/libboost_system.so.1.53.0
-rw-R - R-- 1根根14536окт。 13 07:14 libboost_system.so.1.53.0$ G ++ -I的/ home / THIRD_PARTY /升压/-L/ usr / lib目录/ x86_64的-Linux的GNU /-lboost_system -Wall -m64 boost_async.cpp -o主
/tmp/ccE20K2W.o:在功能`__static_initialization_and_destruction_0(INT,INT):
。TEST.CPP :(文字+ 0x6b):未定义的引用`的boost ::系统:: generic_category()
。TEST.CPP :(文字+ 0x77):未定义的引用`的boost ::系统:: generic_category()
。TEST.CPP :(文字+ 0X83):未定义的引用`的boost ::系统:: system_category()
/tmp/ccE20K2W.o:在功能`提高:: ASIO ::错误:: get_system_category():
test.cpp:(.text._ZN5boost4asio5error19get_system_categoryEv[_ZN5boost4asio5error19get_system_categoryEv]+0x5):未定义的引用`的boost ::系统:: system_category()
collect2:错误:LD返回1退出状态


解决方案

如果您将链接指令 -lboost_system 在像这样的命令行的末尾:

G ++ -I的/ home / THIRD_PARTY /升压/-L/ usr / lib目录/ x86_64的-Linux的GNU /-Wall -m64 boost_async.cpp -o主要-lboost_system

这应该解决的问题。由于科林·贝内特Ð并的wesley.mesquita 澄清这个答案。

I am not good in command-line compiling. My problem is inability to compile simple project, that depends from Boost. The following is a log of my trying:

$ g++ -Wall test.cpp -o main
/tmp/ccCTvBYE.o: In function `__static_initialization_and_destruction_0(int, int)':
test.cpp:(.text+0x6b): undefined reference to `boost::system::generic_category()'
test.cpp:(.text+0x77): undefined reference to `boost::system::generic_category()'
test.cpp:(.text+0x83): undefined reference to `boost::system::system_category()'
/tmp/ccCTvBYE.o: In function `boost::asio::error::get_system_category()':
test.cpp:(.text._ZN5boost4asio5error19get_system_categoryEv[_ZN5boost4asio5error19get_system_categoryEv]+0x5): undefined reference to `boost::system::system_category()'
collect2: error: ld returned 1 exit status

So, there I found instructions for adding-lboost_system or -lboost_system-mt. I got the following:

$ g++ -lboost_system -Wall test.cpp -o main                                                                                                                    
/usr/bin/ld: cannot find -lboost_system
collect2: error: ld returned 1 exit status

$ g++ -lboost_system-mt -Wall test.cpp -o main                                                                                                                 
/usr/bin/ld: cannot find -lboost_system-mt
collect2: error: ld returned 1 exit status

I tried to locate boost_system library.

$ /sbin/ldconfig -p | grep boost_system
    libboost_system.so.1.53.0 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libboost_system.so.1.53.0

Then I unsuccessfully tried the following

$ g++ -I"/home/third_party/boost/" -L"/usr/lib/x86_64-linux-gnu/" -lboost_system -Wall test.cpp -o main
/usr/bin/ld: cannot find -lboost_system
collect2: error: ld returned 1 exit status

Now I am stuck. How to form the command to compile?

Edit:

The following trying didn't help, too.

ln -s /usr/lib/x86_64-linux-gnu/libboost_system.so.1.53.0 /usr/lib/x86_64-linux-gnu/libboost_system.so
ldconfig -n /usr/lib/x86_64-linux-gnu/

$ ll /usr/lib/x86_64-linux-gnu/ | grep boost_system
lrwxrwxrwx   1 root root       51 янв.  21 19:47 libboost_system.so -> /usr/lib/x86_64-linux-gnu/libboost_system.so.1.53.0
-rw-r--r--   1 root root    14536 окт.  13 07:14 libboost_system.so.1.53.0

$ g++ -I"/home/third_party/boost/" -L"/usr/lib/x86_64-linux-gnu/" -lboost_system -Wall -m64 boost_async.cpp -o main
/tmp/ccE20K2W.o: In function `__static_initialization_and_destruction_0(int, int)':
test.cpp:(.text+0x6b): undefined reference to `boost::system::generic_category()'
test.cpp:(.text+0x77): undefined reference to `boost::system::generic_category()'
test.cpp:(.text+0x83): undefined reference to `boost::system::system_category()'
/tmp/ccE20K2W.o: In function `boost::asio::error::get_system_category()':
test.cpp:(.text._ZN5boost4asio5error19get_system_categoryEv[_ZN5boost4asio5error19get_system_categoryEv]+0x5): undefined reference to `boost::system::system_category()'
collect2: error: ld returned 1 exit status

解决方案

If you place the linker directive -lboost_system at the end of the command line like so:

g++ -I"/home/third_party/boost/" -L"/usr/lib/x86_64-linux-gnu/" -Wall -m64 boost_async.cpp -o main -lboost_system

this should solve the problem. Thanks to Colin D Bennett and wesley.mesquita for clarifying this answer.

这篇关于G ++无法找到boost库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆