Linux ldconfig 错误:不是符号链接

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11542255/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 13:50:54  来源:igfitidea点击:

ldconfig error: is not a symbolic link

linuxlinkermakefilegnu-make

提问by Rodrigo Gurgel

When running:

运行时:

    sudo /sbin/ldconfig

the following error appears:

出现以下错误:

    /sbin/ldconfig: /usr/local/lib/ is not a symbolic link

When I run file:

当我运行文件时:

    file /usr/local/lib/
    /usr/local/lib/: directory

Inside /usr/local/lib/there are three libraries that I use. I'll call them here as lib1, lib2and lib3.

里面/usr/local/lib/有我使用的三个库。我将它们称为lib1,lib2lib3

Now, when I do an lddon my binary it results:

现在,当我ldd对我的二进制文件执行 an时,结果是:

    lib1.so => not found
    lib2.so => not found
    lib3.so => /usr/local/lib/lib3.so (0x00216000)

But all of then are in the same folder as /usr/local/lib/{lib1,lib2,lib3}.so.

但所有这些都与/usr/local/lib/{lib1,lib2,lib3}.so.

Every time I run ldconfig, the same error appears:

每次运行时ldconfig,都会出现相同的错误:

/usr/local/lib/ is not a symbolic link

I thought /usr/local/libshould be declared twice in /etc/ld.conf.d/*.conf, but not:

我认为/usr/local/lib应该在 中声明两次/etc/ld.conf.d/*.conf,但不是:

    sudo egrep '\/usr\/local' /etc/ld.so.conf.d/*
    projectA.conf.old:/usr/local/projectA/lib
    local.conf:/usr/local/lib

ld.so.confonly includes /etc/ld.so.conf.d/*.conf, so this *.oldisn't processed, and it refers to /usr/local/projectA/lib.

ld.so.conf只包含/etc/ld.so.conf.d/*.conf,所以这*.old不被处理,它指的是/usr/local/projectA/lib.

After a time tring I deleted all lib1 and lib2 (at some point I tested it on binary's folder), the same error occurs.

经过一段时间后,我删除了所有 lib1 和 lib2(在某些时候我在二进制文件夹中对其进行了测试),发生了同样的错误。

采纳答案by Dan Pritts

I ran into this issue with the Oracle 11R2 client. Not sure if the Oracle installer did this or someone did it here before i arrived. It was not 64-bit vs 32-bit, all was 64-bit.

我在使用 Oracle 11R2 客户端时遇到了这个问题。在我到达之前,不确定 Oracle 安装程序是这样做的还是有人在这里这样做的。不是 64 位 vs 32 位,都是 64 位。

The error was that libexpat.so.1was not a symbolic link.

错误是那libexpat.so.1不是符号链接。

It turned out that there were two identical files, libexpat.so.1.5.2and libexpat.so.1. Removing the offending file and making it a symlink to the 1.5.2 version caused the error to go away.

结果发现有两个相同的文件,libexpat.so.1.5.2libexpat.so.1. 删除有问题的文件并使其成为 1.5.2 版本的符号链接会导致错误消失。

Makes sense that you'd want the well-known name to be a symlink to the current version. If you do this, it's less likely that you'll end up with a stale library.

您希望众所周知的名称是当前版本的符号链接是有道理的。如果你这样做,你最终得到一个陈旧的库的可能性就会降低。

回答by alinsoar

You need to include the path of the libraries inside /etc/ld.so.conf, and rerun ldconfig to upate the list

您需要在 /etc/ld.so.conf 中包含库的路径,然后重新运行 ldconfig 以更新列表

Other possibility is to include in the env variable LD_LIBRARY_PATH the path to your library, and rerun the executable.

另一种可能性是在环境变量 LD_LIBRARY_PATH 中包含库的路径,然后重新运行可执行文件。

check the symbolic links if they point to a valid library ...

检查符号链接是否指向有效的库...

You can add the path directly in /etc/ld.so.conf, without include...

可以直接在/etc/ld.so.conf中添加路径,不包含...

run ldconfig -pto see whether your library is well included in the cache.

运行ldconfig -p以查看您的库是否包含在缓存中。

回答by Rodrigo Gurgel

Solved, at least at the point of the question.

解决了,至少在问题的关键点上。

I searched in the web before asking, an there were no conclusive solution, the reason why this error is: lib1.so and lib2.so are not OK, very probably where not compiled for a 64 PC, but for a 32 bits machine otherwise lib3.so is a 64 bits lib. At least that is my hipothesis.

我问之前在网上搜索过,没有结论性的解决方案,这个错误的原因是:lib1.so 和 lib2.so 不正常,很可能不是为 64 位 PC 编译的,否则为 32 位机器编译lib3.so 是一个 64 位的库。至少这是我的假设。

VERY unfortunately ldconfig doesn't give a clean error message informing that it could not load the library, it only pumps:

非常不幸的是 ldconfig 没有给出干净的错误消息,通知它无法加载库,它只会泵:

ldconfig: /folder_where_the_wicked_lib_is/ is not a symbolic link

ldconfig: /folder_where_the_wicked_lib_is/ 不是符号链接

I solved this when I removed the libs not found by ldd over the binary. Now it's easier that I know where lies the problem.

当我删除 ldd 通过二进制文件找不到的库时,我解决了这个问题。现在我更容易知道问题出在哪里。

My ld version: GNU ld version 2.20.51, and I don't know if a most recent version has a better message for its users.

我的 ld 版本:GNU ld 版本 2.20.51,我不知道最新版本是否对其用户有更好的信息。

Thanks.

谢谢。

回答by Jeetendra_Nath_Jha

I simply ran the command below:

我只是运行了下面的命令:

export LD_LIBRARY_PATH=/usr/lib/

Now it is working fine.

现在它工作正常。

回答by Maxim Akristiniy

simple run in shell : sudo apt-get install --reinstall libexpat1
got same problem with libxcb - solved in this way - very fast :)

在 shell 中简单运行:sudo apt-get install --reinstall libexpat1
遇到了与 libxcb 相同的问题 - 以这种方式解决 - 非常快 :)