hidden symbol `stat' in libc_nonshared.a(stat.oS) is referenced by DSO

試著忘記壹切 提交于 2020-01-06 17:55:39

问题


I'm trying to use methods contained in a shared library (libscplugin.so).

I have satisfied all of the libraries requirements:

  • libc.so with a symlink to libc.so.6
  • libz.so with a symlink to libz.so.1.2.8
  • libstdc++.so with a symlink to libstdc++.so.6.0.20

Upon compilation I get the following error message:

$ 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

The only reference I could find to libc_nonshared.a is in /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 ) )

In test.c I'm attempting to use two functions of the shared library (totally unrelated to stat). What can I do to get this to compile ?


回答1:


Your problem is here:

I have satisfied all of the libraries requirements:

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

That is not a valid setup for glibc. libc.so is supposed to be a text file (linker script) as you saw at the end of your answer. You're doing something weird and unnecessary if you're making symlinks to shared libraries like this yourself. Use the libc.so that's provided (and you need to do this when building your other shared libraries -- your problem right now is that they were mis-linked) and everything will work fine.



来源:https://stackoverflow.com/questions/32143114/hidden-symbol-stat-in-libc-nonshared-astat-os-is-referenced-by-dso

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!