Linking to wrong library version in a C++ application

戏子无情 提交于 2020-01-03 06:44:06

问题


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 symlinked 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.


回答1:


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):

  1. 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).

  2. 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.




回答2:


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.



来源:https://stackoverflow.com/questions/3891692/linking-to-wrong-library-version-in-a-c-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!