简体   繁体   English

为什么LD_LIBRARY_PATH无效?

[英]Why LD_LIBRARY_PATH is not effective?

I'm trying to compile libpng , which requires the libz . 我正在尝试编译libpng ,这需要libz I have installed my owner libz.so.1 at my home and set the LD_LIBRARY_PATH .But it does not get any result because the output of ldd shows that it still uses /usr/local/lib/libz.so.1 . 我已经在我家安装了我的所有者libz.so.1并设置了LD_LIBRARY_PATH 。但它没有得到任何结果,因为ldd的输出显示它仍然使用/usr/local/lib/libz.so.1

And then the output of make shows like "-L/home/zlib -lz". 然后make的输出显示为“-L / home / zlib -lz”。 Why? 为什么?

Probably you need a symbolic link from /home/mylibs/libz.so to /home/mylibs/libz.so.1 . 您可能需要从/home/mylibs/libz.so/home/mylibs/libz.so.1的符号链接。

Note that -lz will search for libz.so , but not libz.so.1 , so the linker will keep on searching and will find such a link in /usr/local/lib . 请注意, -lz将搜索libz.so ,但不搜索libz.so.1 ,因此链接器将继续搜索并在/usr/local/lib找到这样的链接。

Other than that, you make want to show the NEEDED entries (which record dynamic dependencies) in the header of your executable, with: 除此之外,您还希望在可执行文件的标题中显示NEEDED条目(记录动态依赖项),其中:

$ objdump -x a.out | grep NEEDED

to see if they are recorded with the full path, as libz.so or as libz.so.1 . 查看它们是否以完整路径记录,如libz.solibz.so.1

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

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