简体   繁体   English

使用boost运行LD_PRELOAD时出错

[英]Error when run LD_PRELOAD with boost

I compiled LD_PRELOAD which uses boost (locks.hpp). 我编译了使用boost(locks.hpp)的LD_PRELOAD。 Compile was successfull. 编译成功。 I copied this LD_PRELOAD to other linux server, and when i run, error: 我将此LD_PRELOAD复制到其他linux服务器,运行时出现错误:

/usr/bin/java: symbol lookup error: /test/test.so: undefined symbol: _ZN5boost11this_thread20disable_interruptionC1Ev / usr / bin / java:符号查找错误:/test/test.so:未定义符号:_ZN5boost11this_thread20disable_interruptionC1Ev

How can i fix this? 我怎样才能解决这个问题? Can i avoid this problem without installing boost on this server? 如果不在此服务器上安装Boost,是否可以避免此问题?

How i compile LD_PRELOAD: 我如何编译LD_PRELOAD:

g++ -fPIC -m32  -shared -Wl,-soname,test.so -ldl -o test.so test.cpp

Thanks! 谢谢!

It seems you have to get libboost_thread into your test.so file. 看来您必须将libboost_thread放入test.so文件中。 Something along the lines of: 类似于以下内容:

g++ -fPIC -m32  -shared -Wl,-soname,test.so -ldl -o test.so test.cpp \ 
  /usr/lib/libboost_thread.a -lpthread

Since I wouldn't know the specifics for your system, the boost library might be in a different place than from mine. 由于我不知道您系统的详细信息,因此boost库可能与我的库不在同一个地方。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM