LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   gcc linker error - hidden symbol `stat' in /usr/lib/libc_nonshared.a(stat.oS) (https://www.linuxquestions.org/questions/linux-software-2/gcc-linker-error-hidden-symbol-%60stat-in-usr-lib-libc_nonshared-a-stat-os-755962/)

chaosless 09-17-2009 12:20 PM

gcc linker error - hidden symbol `stat' in /usr/lib/libc_nonshared.a(stat.oS)
 
Am getting this linker error from gcc on linux:

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

The complaint is from my library, all objects rebuilt by v4.3.2 gcc and g++. And yes some of the routines do call stat()

apologies if this is a compiler/linker option that i've missed but am able to link on opensolaris and other platforms just fine, so wondered if is a linux-gcc issue that might already be answered here?

i've tried a few options building my DSO... including -shared but it seems like stat() is a weak symbol that does not resolve?

Thanks,
/j

---

here's some details if that helps...

ld --version == 2.19.1

/usr/lib/libc.so is actually this linker script:
/* GNU ld script
Use the shared library, but some functions are only in
the static library, so try that secondarily. */
OUTPUT_FORMAT(elf32-i386)
GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a AS_NEEDED ( /lib/ld-linux.so.2 ) )

/lib/libc.so.6 is symbolic link to /lib/libc-2.9.so

readelf -s /lib/libc-2.9.so doesn't show stat() exported

/usr/lib/libc_nonshared.a (also in /usr/lib/libc.a) defines stat as a weak symbol:

00000000 W stat

chaosless 09-17-2009 12:33 PM

well clearly it was my libraries - not checked what gcc does differently - but letting gcc build the libraries cleaned that up...

ar x ../libXXXX.a
gcc --shared -o ../libXXXX.so *.o

no longer get the complaint linking with my -lXXXX


All times are GMT -5. The time now is 05:15 PM.