Linking to wrong library version in a C++ application
I'm troubleshooting a C++ binary on RHEL/CentOS 5, which has problems with the openssl shared libraries. I don't do much C/C++ programming, and I'm having trouble finding the root issue.
What seems to be going wrong is that the application is linking to specific versions of libcrypto and libssl (0.9.8), instead of the syml开发者_如何学运维inked paths of /lib/libcrypto.so.6
and /lib/libssl.so.6
. Since the openssl libs have been updated since this was compiled, it's now broken.
ldd
shows the following 2 problems with the binary:
libcrypto.so.0.9.8 => not found
libssl.so.0.9.8 => not found
[EDIT] I obtained the source, and it built correctly. I'm going to have to go with the simplest possible explanation, the build machine was misconfigured with non-standard libraries, and the makefiles are fine.
A couple suggestions (i'm assuming you have no way of getting a new binary that links to the new versions of the ssl libs):
Get the old versions of the libs from the previous version of the package and keep them around just for your binary (you could put them somewhere out of /usr/lib and load them just for your program with LD_LIBRARY_PATH).
Force loading the new versions of the libs with LD_PRELOAD and hope all the symbols the binary needs are there and the binary actually runs. This has a quite slim chance of working, but it's worth a try.
D'oh, I'd misread the question as troubleshooting a binary that you were building yourself.
You can use ldd your-binary
to check which libraries it will load at runtime.
If it's deliberately loading a different version, you should check the LD_LIBRARY_PATH
environment and the loader configuration in /etc/ld.so.config
for the list of paths to load libraries from. Alternatively the loader path might be hard-coded into your binary using -rpath
switches on the link line - look for these in your Makefile.
精彩评论