Linux 错误:ld.so:无法预加载对象 LD_PRELOAD:忽略
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17723666/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ERROR: ld.so: object LD_PRELOAD cannot be preloaded: ignored
提问by lulyon
I am using ubuntu 12.04. Every time I start my bash terminal and every time when I finish typing a command(and press enter) , I get this message:
我正在使用 ubuntu 12.04。每次我启动我的 bash 终端以及每次我完成输入命令(并按 Enter)时,我都会收到以下消息:
ERROR: ld.so: object '/usr/lib/liblunar-calendar-preload.so' from LD_PRELOAD cannot be preloaded: ignored.
错误:ld.so:无法预加载来自 LD_PRELOAD 的对象“/usr/lib/liblunar-calendar-preload.so”:忽略。
It is weird. So what is the environment variable LD_PRELOAD used for? And what is the going on behind the scene?
真奇怪。那么环境变量 LD_PRELOAD 是干什么用的呢?幕后发生了什么?
Thanks.
谢谢。
采纳答案by hetepeperfan
The linker takes some environment variables into account. one is LD_PRELOAD
链接器考虑了一些环境变量。一个是LD_PRELOAD
from man 8 ld-linux
:
来自man 8 ld-linux
:
LD_PRELOAD
A whitespace-separated list of additional, user-specified, ELF
shared libraries to be loaded before all others. This can be
used to selectively override functions in other shared
libraries. For setuid/setgid ELF binaries, only libraries in
the standard search directories that are also setgid will be
loaded.
Therefore the linker will try to load libraries listed in the LD_PRELOAD
variable before others are loaded.
因此,链接器将尝试在加载其他库LD_PRELOAD
之前加载变量中列出的库。
What could be the case that inside the variable is listed a library that can't be pre-loaded. look inside your .bashrc
or .bash_profile
environment where the LD_PRELOAD
is set and remove that library from the variable.
可能是在变量内部列出了一个无法预加载的库的情况。查看您的.bashrc
或设置的.bash_profile
环境LD_PRELOAD
并从变量中删除该库。
回答by lulyon
Thanks for the responses. I think I've solved the problem just now.
感谢您的回复。我想我已经解决了刚才的问题。
Since LD_PRELOAD is for setting some library proloaded, I check the library that ld preloads with LD_PRELOAD, one of which is "liblunar-calendar-preload.so", that is not existing in the path "/usr/lib/liblunar-calendar-preload.so", but I find a similar library "liblunar-calendar-preload-2.0.so", which is a difference version of the former one.
由于 LD_PRELOAD 是为了设置一些预加载的库,我检查了 ld 用 LD_PRELOAD 预加载的库,其中之一是“liblunar-calendar-preload.so”,它不存在于路径“/usr/lib/liblunar-calendar- preload.so”,但我找到了一个类似的库“liblunar-calendar-preload-2.0.so”,它是前者的不同版本。
Then I guess maybe liblunar-calendar-preload.so was updated to a 2.0 version when the system updated, leaving LD_PRELOAD remain to be "/usr/lib/liblunar-calendar-preload.so". Thus the preload library name was not updated to the newest version.
然后我想也许 liblunar-calendar-preload.so 在系统更新时更新为 2.0 版本,而 LD_PRELOAD 仍然是“/usr/lib/liblunar-calendar-preload.so”。因此,预加载库名称未更新为最新版本。
To avoid changing environment variable, I create a symbolic link under the path "/usr/lib"
为了避免改变环境变量,我在路径“/usr/lib”下创建了一个符号链接
sudo ln -s liblunar-calendar-preload-2.0.so liblunar-calendar-preload.so
Then I restart bash, the error is gone.
然后我重新启动bash,错误消失了。
回答by Einar
If you want to make sure that the library is loaded if and only ifthe program lunar-calendar-gtk
is launched, you can apply this:
如果您想确保当且仅当程序lunar-calendar-gtk
启动时才加载库,您可以应用:
You set the environment variable per command by prefixing the command with it:
您可以通过为命令添加前缀来设置每个命令的环境变量:
$ LD_PRELOAD="liblunar-calendar-preload.so" printenv "LD_PRELOAD"
liblunar-calendar-preload.so
$ printenv "LD_PRELOAD"
$
You can then choose to put this in a shell script and make lunar-calendar-gtk
a symlink to this shell script, replaceing the original referencee. This effectively makes sure that the library is loaded everytime the original application is executed.
然后你可以选择把它放在一个 shell 脚本中,并创建lunar-calendar-gtk
一个到这个 shell 脚本的符号链接,替换原来的引用。这有效地确保每次执行原始应用程序时都加载库。
You will have to rename the original lunar-calendar-gtk
to something else, which might not be too intriguing as it possibly may cause issues with uninstallation and upgrading. However, I found it useful with a former version of Skype.
您必须将原始文件重命名为lunar-calendar-gtk
其他名称,这可能不会太吸引人,因为它可能会导致卸载和升级问题。但是,我发现它对以前版本的 Skype 很有用。
回答by purplesky
It means the path you input caused an error. In your LD_PRELOAD
command, modify the path like the error tips:
这意味着您输入的路径导致错误。在您的LD_PRELOAD
命令中,像错误提示一样修改路径:
/usr/lib/liblunar-calendar-preload.so
回答by DaSqy Stc
You can check /etc/ld.so.preloadfile content
您可以检查/etc/ld.so.preload文件内容
I fix it by:
我通过以下方式修复它:
echo "" > /etc/ld.so.preload
echo "" > /etc/ld.so.preload