我正在重新编译一个不属于我的项目。
我有一个项目的二进制版本,我决定破解它,所以我下载了二进制版本的源代码,并尝试重新编译它。
它有效,除了一件事困扰我:在Windows上(但我在Linux上发现了关于这一点的问题)我的重编译版本想要libpng14-14.dll但官方二进制文件想要libpng15-15.dll
我想知道原因。
我在Ubuntu论坛上看到一些关于Snex9x模拟器的帖子在Linux上有相同的问题(有些版本需要libpng14.so和其他libpng15.so)
那么,GCC如何定义编译程序运行时所查找的库的文件名是什么?
答案 0 :(得分:0)
对于linux,man ld:
The linker uses the following search paths to locate required shared libraries:
1. Any directories specified by -rpath-link options.
2. Any directories specified by -rpath options. The difference between -rpath and -rpath-link is that directories specified
by -rpath options are included in the executable and used at runtime, whereas the -rpath-link option is only effective at
link time. Searching -rpath in this way is only supported by native linkers and cross linkers which have been configured
with the --with-sysroot option.
3. On an ELF system, if the -rpath and "rpath-link" options were not used, search the contents of the environment variable
"LD_RUN_PATH". It is for the native linker only.
4. On SunOS, if the -rpath option was not used, search any directories specified using -L options.
5. For a native linker, the contents of the environment variable "LD_LIBRARY_PATH".
6. For a native ELF linker, the directories in "DT_RUNPATH" or "DT_RPATH" of a shared library are searched for shared
libraries needed by it. The "DT_RPATH" entries are ignored if "DT_RUNPATH" entries exist.
7. The default directories, normally /lib and /usr/lib.
8. For a native linker on an ELF system, if the file /etc/ld.so.conf exists, the list of directories found in that file.
If the required shared library is not found, the linker will issue a warning and continue with the link.