简体   繁体   中英

Error when run LD_PRELOAD with boost

I compiled LD_PRELOAD which uses boost (locks.hpp). Compile was successfull. I copied this LD_PRELOAD to other linux server, and when i run, error:

/usr/bin/java: symbol lookup error: /test/test.so: undefined symbol: _ZN5boost11this_thread20disable_interruptionC1Ev

How can i fix this? Can i avoid this problem without installing boost on this server?

How i compile 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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