链接boost_1_55_0 ASIO [英] Linking boost_1_55_0 asio
问题描述
我在我的Makefile使用它来构建我的程序:
I'm using this in my makefile to build my program:
all: server.cpp
g++ -o server server.cpp -I ~/boost/include -L~/boost/lib -Wl,-rpath,~/boost/lib -lboost_system -lboost_thread -DBOOST_ALL_NO_LIB=1
当我编译我得到这些警告:
When I compile I get these warnings:
/usr/bin/ld: warning: libboost_system.so.1.53.0, needed by /usr/local/lib/libboost_thread.so, may conflict with libboost_system.so.5
当我运行我的程序,我收到了警告:
When I run my program I receive the warning :
./server: error while loading shared libraries: libboost_thread.so.1.53.0: cannot open shared object file: No such file or directory
在-Wl / rpath的指令此刻不为我工作。我一直在使用还累
the -Wl/rpath command is not working for me at the moment. I have also tired using
export LD_LIBRARY_PATH=~/boost/lib
在我运行了一个程序,我从这个码头回:
before I run my program and I get this back from the terminal:
export: relocation error: export: symbol errno, version GLIBC_2.0 not defined in file libc.so.6 with link time reference
我能做些什么来指定我想,当我执行程序使用什么样的图书馆吗?
What can I do to specify what library I want to use when I execute the program?
推荐答案
的库(通常)升压/ lib中/台/ lib目录
,而不是升压/ lib目录
。
The libraries are (usually) boost/lib/stage/lib
, not boost/lib
.
另外,动态加载程序的不支持〜
扩展。使用完全合格的路径,例如
Also the dynamic loader does not support ~
expansion. Use the fully qualified path, e.g.
-Wl,-rpath,/home/hededo/boost/stage/lib
或者更确切地说,我表现出我的previous答案
Or, indeed, as I showed in my previous answer
-Wl,-rpath,"$HOME/boost/stage/lib"
的引号只是为了工作,如果 $ HOME
包含特殊字符(如空格)
The quotes are just to make it work if $HOME
contains special characters (like whitespace)
您也可以看看
- static linking - so you can use Boost but never rely on any external shared library for it
- the BCP utility is a tool for extracting subsets of Boost (here: bcp)
这篇关于链接boost_1_55_0 ASIO的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!