GCC链接到不存在的库。

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

GCC links to library that does not exist

问题

不会有两个库一起生成一个甚至不存在的第三个库吗?

请在这里尝试

确保您的机器上安装了icu和g++

输出

ldd out1:
	linux-vdso.so.1 (0x00007ffd5cdaf000)
	liblcf.so.0 => /home/aleck099/.local/lib/liblcf.so.0 (0x00007ff200600000)
	libicuuc.so.72 => /usr/lib/libicuuc.so.72 (0x00007ff200200000)
	libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007ff1ffe00000)
	libm.so.6 => /usr/lib/libm.so.6 (0x00007ff200518000)
	libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007ff2008a1000)
	libc.so.6 => /usr/lib/libc.so.6 (0x00007ff1ffc19000)
	libicui18n.so.71 => 未找到
	libicuuc.so.71 => 未找到
	libicudata.so.71 => 未找到
	libexpat.so.1 => /usr/lib/libexpat.so.1 (0x00007ff200874000)
	libicudata.so.72 => /usr/lib/libicudata.so.72 (0x00007ff1fde00000)
	/lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007ff2008ea000)
ldd out2:
	linux-vdso.so.1 (0x00007ffdfed78000)
	libicui18n.so.72 => /usr/lib/libicui18n.so.72 (0x00007fa088000000)
	libicuuc.so.72 => /usr/lib/libicuuc.so.72 (0x00007fa087c00000)
	libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007fa087800000)
	libm.so.6 => /usr/lib/libm.so.6 (0x00007fa08834d000)
	libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007fa087fe0000)
	libc.so.6 => /usr/lib/libc.so.6 (0x00007fa087619000)
	libicudata.so.72 => /usr/lib/libicudata.so.72 (0x00007fa085800000)
	/lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007fa08845e000)

您可以看到在out1的ldd输出中有三个"未找到"。

它们甚至是现有icu库的副本。

这是怎么发生的?

其他信息

  • clang和gcc都会产生相同的结果
  • liblcf.so是从easyrpg构建的。
英文:

Will two libraries together produce a third library that does not even exist?

Try it here

Make sure there are icu and g++ on your machine

Output

ldd out1:
	linux-vdso.so.1 (0x00007ffd5cdaf000)
	liblcf.so.0 => /home/aleck099/.local/lib/liblcf.so.0 (0x00007ff200600000)
	libicuuc.so.72 => /usr/lib/libicuuc.so.72 (0x00007ff200200000)
	libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007ff1ffe00000)
	libm.so.6 => /usr/lib/libm.so.6 (0x00007ff200518000)
	libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007ff2008a1000)
	libc.so.6 => /usr/lib/libc.so.6 (0x00007ff1ffc19000)
	libicui18n.so.71 => not found
	libicuuc.so.71 => not found
	libicudata.so.71 => not found
	libexpat.so.1 => /usr/lib/libexpat.so.1 (0x00007ff200874000)
	libicudata.so.72 => /usr/lib/libicudata.so.72 (0x00007ff1fde00000)
	/lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007ff2008ea000)
ldd out2:
	linux-vdso.so.1 (0x00007ffdfed78000)
	libicui18n.so.72 => /usr/lib/libicui18n.so.72 (0x00007fa088000000)
	libicuuc.so.72 => /usr/lib/libicuuc.so.72 (0x00007fa087c00000)
	libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007fa087800000)
	libm.so.6 => /usr/lib/libm.so.6 (0x00007fa08834d000)
	libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007fa087fe0000)
	libc.so.6 => /usr/lib/libc.so.6 (0x00007fa087619000)
	libicudata.so.72 => /usr/lib/libicudata.so.72 (0x00007fa085800000)
	/lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007fa08845e000)

You can see that three "not found"s in the ldd output of out1

They are even duplicates of existing icu libraries

How could this happen?

Other information

  • both clang and gcc produce the same result
  • liblcf.so is built from easyrpg

答案1

得分: 2

看起来用于创建out1的链接命令捕获了来自两个不同版本的ICU库的符号:libicuuc.so.71libicuuc.so.72。71与72是版本号。这些似乎是位于链接器库路径中的两个不同版本的共享库。在ldd时显示为“未找到”,因为其中一个副本不在运行时共享库搜索路径中,即使混合使用也可能不是一个好主意。

解决方案可能是检查您的链接命令,并确保-L选项只包含ICU库的一个版本/副本。

编辑:启用详细信息的链接(使用g++ -v选项)将提供有关正在使用的库和路径的附加信息。

请注意,out1引入的某些共享库可能会传递引入(不存在的)libicuuc.so.71。比较您的两个ldd可执行文件输出时,我会怀疑/home/aleck099/.local/lib/liblcf.so.0(可能还有/usr/lib/libexpat.so.1)只出现在out1中。以下命令可能有所帮助:

$ ldd /home/aleck099/.local/lib/liblcf.so.0 /usr/lib/libexpat.so.1
英文:

It looks like the link command used to create out1 picked up symbols from two different versions of the ICU library: libicuuc.so.71 and libicuuc.so.72. The 71 vs 72 is the version number. Those appear to be two different versions of the shared library that were both in the linker's library path. It's "not found" at ldd time because one copy is not in the runtime shared library search path, and even if it was mixing both is probably a bad idea.

The solution is likely to inspect your link command and ensure the -L options only include one version/copy of the ICU library.

EDIT: Linking with verbosity enabled (g++ -v option) will provide additional information about the libraries and paths being used.

Note that it's possible that some of the shared libraries pulled in by out1 are transitively pulling in the (non-existent) libicuuc.so.71. Comparing your two ldd executable outputs, I would be suspicious of /home/aleck099/.local/lib/liblcf.so.0 (and possibly /usr/lib/libexpat.so.1) that only appear in out1. The following command may help:

$ ldd /home/aleck099/.local/lib/liblcf.so.0 /usr/lib/libexpat.so.1

huangapple
  • 本文由 发表于 2023年1月8日 23:37:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/75049082.html
匿名

发表评论

匿名网友

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

确定