gpt4 book ai didi

c - libc_nonshared.a(stat.oS) 中的隐藏符号 `stat' 被 DSO 引用

转载 作者:行者123 更新时间:2023-11-30 17:11:31 35 4
gpt4 key购买 nike

我正在尝试使用共享库 (libscplugin.so) 中包含的方法。

我已经满足了库的所有要求:

  • libc.so 带有指向 libc.so.6
  • 的符号链接(symbolic link)
  • libz.so 带有指向 libz.so.1.2.8
  • 的符号链接(symbolic link)
  • libstdc++.so 带有指向 libstdc++.so.6.0.20
  • 的符号链接(symbolic link)

编译后我收到以下错误消息:

$ gcc test.c -o test -L/usr/lib/arm-linux-gnueabihf/ -lscplugin
/usr/bin/ld: test: hidden symbol `stat' in /usr/lib/arm-linux-gnueabihf/libc_nonshared.a(stat.oS) is referenced by DSO
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status

我能找到的对libc_nonshared.a的唯一引用是在/usr/lib/arm-linux-gnueabihf/libc.so中:

$ cat libc.so
/* GNU ld script
Use the shared library, but some functions are only in
the static library, so try that secondarily. */
OUTPUT_FORMAT(elf32-littlearm)
GROUP ( /lib/arm-linux-gnueabihf/libc.so.6 /usr/lib/arm-linux-gnueabihf/libc_nonshared.a AS_NEEDED ( /lib/arm-linux-gnueabihf/ld-linux-armhf.so.3 ) )

test.c 中,我尝试使用共享库的两个函数(与 stat 完全无关)。我该怎么做才能编译它?

最佳答案

您的问题在这里:

I have satisfied all of the libraries requirements:

  • libc.so with a symlink to libc.so.6

这不是 glibc 的有效设置。正如您在答案末尾看到的那样,libc.so 应该是一个文本文件(链接器脚本)。如果您自己创建指向共享库的符号链接(symbolic link),那么您正在做一些奇怪且不必要的事情。使用提供的 libc.so (您需要在构建其他共享库时执行此操作 - 您现在的问题是它们链接错误),一切都会正常工作。

关于c - libc_nonshared.a(stat.oS) 中的隐藏符号 `stat' 被 DSO 引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32143114/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com