2014-04-07 48 views
1

我在我的makefile使用它来构建我的程序:链接boost_1_55_0 ASIO

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 

当我编译我得到这些警告:

/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 

当我运行我的程序,我收到了警告:

./server: error while loading shared libraries: libboost_thread.so.1.53.0: cannot open shared object file: No such file or directory 

-Wl/rpath命令此刻不适用于我。我也厌倦了使用

export LD_LIBRARY_PATH=~/boost/lib 

我运行了一个程序,我从终端这回前:

export: relocation error: export: symbol errno, version GLIBC_2.0 not defined in file libc.so.6 with link time reference 

我能做些什么来指定我想,当我执行程序使用什么库?

回答

1

这些库(通常)boost/lib/stage/lib,不boost/lib

另外动态加载器不支持~扩展。使用完全合格的路径,例如

-Wl,-rpath,/home/hededo/boost/stage/lib 

,或者更确切地说,正如我在前面的回答表明

-Wl,-rpath,"$HOME/boost/stage/lib" 

的引号只是为了工作,如果$HOME包含特殊字符(如空格)

你也可以看看在

  • static linking - 所以你可以使用升压,但不要依靠任何外部升共享库吧
  • BCP实用工具是用于加速的提取子集(这里:bcp)工具
0

或者,您可以使用non-boost asio,它不需要与boost进行链接。

+0

有趣的说法。我正在研究这个。谢谢 – hededo

+0

我认为大多数库可以 - 可选地 - 配置为仅适用于Boost的头文件。然后,有** [静态链接](http://www.boost.org/boost-build2/doc/html/bbv2/tutorial/linkage.html)**和[BCP实用程序是提取子集的工具[Boost](http://www.boost.org/doc/libs/1_55_0/tools/bcp/doc/html/index.html)。这两种方法都更适用于海事组织。 – sehe

+0

我不认为阿西欧有这种选择;它取决于升压系统(并可选地增加线程)以获得错误代码。您可以随时在您的项目中包含该cpp。 BCP不是很可靠。根据我的经验,您最终需要修补BCP产生的部分内容。 – ppl