librav1e: 在加载共享库libc.so时出现错误:无效的ELF头部

huangapple go评论70阅读模式
英文:

librav1e: error while loading shared library libc.so: invalid ELF header

问题

我正在尝试使用librav1e的预编译二进制文件:https://github.com/xiph/rav1e/releases/tag/v0.6.6

更具体地说,我正在使用librav1e-0.6.6-linux-aarch64.tar.gz(还尝试了相同结果的每周构建)在Ubuntu 18.04上。

当我尝试编译另一个依赖于librav1e的库时出现以下错误:

[ 84%] Linking CXX executable heif-test
/usr/bin/ld: warning: libc.so, needed by //usr/local/lib/librav1e.so.0, not found (try using -rpath or -rpath-link)
/usr/local/lib/librav1e.so.0: undefined reference to `fstat64'
/usr/local/lib/librav1e.so.0: undefined reference to `stat64'
collect2: error: ld returned 1 exit status

检查.so文件:

# tar xvf librav1e-linux-aarch64.tar.gz 
include/
include/rav1e/
include/rav1e/rav1e.h
lib/
lib/librav1e.a
lib/librav1e.so
lib/librav1e.so.0.6.1
lib/librav1e.so.0
lib/pkgconfig/
lib/pkgconfig/rav1e.pc

# ldd ./lib/librav1e.so
./lib/librav1e.so: error while loading shared libraries: /usr/lib/aarch64-linux-gnu/libc.so: invalid ELF header

# dpkg -S libc.so
libc6-dev:arm64: /usr/lib/aarch64-linux-gnu/libc.so
libc6:arm64: /lib/aarch64-linux-gnu/libc.so.6

# cat /usr/lib/aarch64-linux-gnu/libc.so
/* GNU ld script
   Use the shared library, but some functions are only in
   the static library, so try that secondarily.  */
OUTPUT_FORMAT(elf64-littleaarch64)
GROUP ( /lib/aarch64-linux-gnu/libc.so.6 /usr/lib/aarch64-linux-gnu/libc_nonshared.a  AS_NEEDED ( /lib/aarch64-linux-gnu/ld-linux-aarch64.so.1 ) )

# rm /usr/lib/aarch64-linux-gnu/libc.so
# ldd ./lib/librav1e.so
    linux-vdso.so.1 (0x0000ffff95b61000)
    libgcc_s.so.1 => /lib/aarch64-linux-gnu/libgcc_s.so.1 (0x0000ffff9590d000)
    libc.so => not found
    libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000ffff957b4000)
    /lib/ld-linux-aarch64.so.1 (0x0000ffff95b35000)

看起来在librav1e.so中有两个共享版本的libc.so,其中一个是我系统中的GNU ld脚本。这样可以吗?我该如何处理这些错误?

英文:

I'm trying to use precompiled binaries of librav1e: https://github.com/xiph/rav1e/releases/tag/v0.6.6

More precisely, I'm using librav1e-0.6.6-linux-aarch64.tar.gz (also tried weekly build with the same result) on Ubuntu 18.04.

When I'm trying to compile another library which is depends on librav1e:

[ 84%] Linking CXX executable heif-test
/usr/bin/ld: warning: libc.so, needed by //usr/local/lib/librav1e.so.0, not found (try using -rpath or -rpath-link)
/usr/local/lib/librav1e.so.0: undefined reference to `fstat64'
/usr/local/lib/librav1e.so.0: undefined reference to `stat64'
collect2: error: ld returned 1 exit status

Inspecting .so file:

# tar xvf librav1e-linux-aarch64.tar.gz 
include/
include/rav1e/
include/rav1e/rav1e.h
lib/
lib/librav1e.a
lib/librav1e.so
lib/librav1e.so.0.6.1
lib/librav1e.so.0
lib/pkgconfig/
lib/pkgconfig/rav1e.pc

# ldd ./lib/librav1e.so
./lib/librav1e.so: error while loading shared libraries: /usr/lib/aarch64-linux-gnu/libc.so: invalid ELF header

# dpkg -S libc.so
libc6-dev:arm64: /usr/lib/aarch64-linux-gnu/libc.so
libc6:arm64: /lib/aarch64-linux-gnu/libc.so.6

# cat /usr/lib/aarch64-linux-gnu/libc.so
/* GNU ld script
   Use the shared library, but some functions are only in
   the static library, so try that secondarily.  */
OUTPUT_FORMAT(elf64-littleaarch64)
GROUP ( /lib/aarch64-linux-gnu/libc.so.6 /usr/lib/aarch64-linux-gnu/libc_nonshared.a  AS_NEEDED ( /lib/aarch64-linux-gnu/ld-linux-aarch64.so.1 ) )

# rm /usr/lib/aarch64-linux-gnu/libc.so
# ldd ./lib/librav1e.so
    linux-vdso.so.1 (0x0000ffff95b61000)
    libgcc_s.so.1 => /lib/aarch64-linux-gnu/libgcc_s.so.1 (0x0000ffff9590d000)
    libc.so => not found
    libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000ffff957b4000)
    /lib/ld-linux-aarch64.so.1 (0x0000ffff95b35000)

So it looks like there two shared versions of libc.so in librav1e.so and one of them is GNU ld script in my system. Is this ok? What can I do with errors?

答案1

得分: 1

您正在使用的软件包链接不正确。在Linux上,每个用于公共使用的共享库都有一个SONAME,它指定了共享库的路径。此值应包含未经修饰的名称,其格式应为libfoo.so.N,其中_foo_是共享库名称,_N_是ABI版本。不同的_N_值会导致不兼容的库。

将库直接链接到诸如libc.so之类的名称是不可接受的,因为它不包含ABI版本。现在,glibc更改其ABI版本的可能性极低,但过去曾经存在不同版本的libc,您不希望将使用glibc 2(libc.so.6)的程序与使用libc5(libc.so.5)的程序链接起来。正确编译用于公共使用的库不会以这种方式链接到libc。

您不应删除/usr/lib/aarch64-linux-gnu/libc.so(如果已经安装了提供它的软件包,则应重新安装它),要么自己编译共享库,要么向维护者报告问题。

请注意,较新版本的Debian和Ubuntu提供此软件包,因此您可能会发现下载该源软件包并进行构建,根据需要进行修改很有帮助,这将以适用于您的操作系统的方式构建它。但是,由于Ubuntu 18.04不再定期接收更新(包括安全更新),这可能会变得更加困难。

英文:

The package you're using is not correctly linked. On Linux, every shared library installed for public use has an SONAME, which specifies the shared library path. This value should contain the unqualified name, which should be in the form libfoo.so.N, where foo is the shared library name, and N is the ABI version. Different values of N result in incompatible libraries.

It isn't acceptable to link libraries directly against a name such as libc.so, since that doesn't contain an ABI version. Now, it is extremely unlikely that glibc will change its ABI version, but in the past, there were different versions of libc, and you would not want to link a program using glibc 2 (libc.so.6) with a program using libc5 (libc.so.5). Libraries that are correctly compiled for public use will not link against libc in this way.

You should not delete /usr/lib/aarch64-linux-gnu/libc.so (and you should re-install the package providing it if you have), and either compile the shared library yourself or report the problem to the maintainer.

Note that newer versions of Debian and Ubuntu ship this package, so you may find that it's helpful to download that source package and build it, modifying as necessary, which will build it in a way that works with your OS. That may, however, be made more difficult by the fact that Ubuntu 18.04 is no longer receiving regular updates, security or otherwise.

huangapple
  • 本文由 发表于 2023年7月11日 05:10:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/76657363.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定