undefined reference to __fgetc_unlocked

Joakim Tjernlund joakim.tjernlund at transmode.se
Wed Nov 23 09:17:42 UTC 2005


Hi Jun

For now I think you should remove the "attribute_hidden" in:
  ./uClibc/libc/stdio/fgetc.c:int attribute_hidden __fgetc_unlocked(FILE
*stream)
until a proper correction has been considered.

 Jocke

> -----Original Message-----
> From: uclibc-bounces at uclibc.org 
> [mailto:uclibc-bounces at uclibc.org] On Behalf Of Jun Sun
> Sent: 23 November 2005 08:25
> To: uclibc at uclibc.org
> Subject: Re: undefined reference to __fgetc_unlocked
> 
> 
> It appears this problem happens when both __STDIO_GETC_MACRO and
> __UCLIBC_HAS_THREADS__ are defined.  You can see in 
> bits/uClibc_stdio.h
> how __fgetc_unlocked() creeps in when fgetc() is called:
> 
> fgetc() ---> (macro)
> 	__FGETC --> (macro)
> 		__GETC_UNLOCKED_MACRO ---> (macro)
> 			__fgetc_unlocked()
> 
> If __DO_UNLOCKED is *not* defined, then __fgetc_unlocked would *not*
> be defined.
> 
> Should I turned off __STDIO_GETC_MACRO?  Uclibc gurus, please help!
> 
> Cheers.
> 
> Jun
> 
> On Tue, Nov 22, 2005 at 05:32:17PM -0800, Jun Sun wrote:
> > I hit this problem when building gdbreplay and later on 
> busybox itself
> > if I skip building gdbreplay.  See the output below.
> > 
> > Yes, I know it is a FAQ item.  But apparently the answer 
> does not apply
> > to my case.
> > 
> > I did a macro expansion and found out that this function is indeed 
> > introduced by uClibc itself.  Here is an excerpt of the 
> expanded gdbreplay.c
> > 
> > # 402 
> "/home/jsun/work/buildroot/snapshot-051122/buildroot/build_arm
> _nofpu/staging_dir/bin-ccache/../lib/gcc/arm-linux-uclibc/3.4.
> 2/../../../../arm-linux-uclibc/sys-include/bits/uClibc_stdio.h" 3 4
> > extern int __fgetc_unlocked(FILE *__stream);
> > extern int __fputc_unlocked(int __c, FILE *__stream);
> > 
> > ...
> > 
> > static int
> > logchar (FILE *fp)
> > {
> >   int ch;
> >   int ch2;
> > 
> >   ch = (__extension__ ({ FILE *__S = (fp); 
> ((__S->__user_locking ) ? ( ((__S)->__bufpos < 
> (__S)->__bufgetc_u) ? (*(__S)->__bufpos++) : 
> __fgetc_unlocked(__S) ) : (fgetc)(__S)); }) );
> > 
> > ...
> > 
> > I also notice uClibc comes with an implementation of this function:
> > 
> > ./uClibc/libc/stdio/fgetc.c:int attribute_hidden 
> __fgetc_unlocked(FILE *stream)
> > 
> > But for some (maybe __DO_UNLOCKED is not defined?), that function
> > is actually not compiled.  Or at least it looks like way.
> > 
> > Anybody has an idea what is the solution here?
> > 
> > BTW, I tried buildroot around Sept 1st and did not encounter this
> > problem.  I assume this is a new problem?
> > 
> > Thanks.
> > 
> > Jun
> > 
> > -------------------
> > 
> > 
> /home/jsun/work/buildroot/snapshot-051122/buildroot/build_arm_
> nofpu/staging_dir/bin/arm-linux-uclibc-gcc -c -Wall -g -O2 
> -Os -pipe    -I. 
> -I/home/jsun/work/buildroot/snapshot-051122/buildroot/toolchai
> n_build_arm_nofpu/gdb-6.3/gdb/gdbserver 
> -I/home/jsun/work/buildroot/snapshot-051122/buildroot/toolchai
n_build_arm_nofpu/gdb-6.3/gdb/gdbserver/../regformats ->
I/home/jsun/work/buildroot/snapshot-051122/buildroot/toolchain
> _build_arm_nofpu/gdb-6.3/gdb/gdbserver/../../include 
> -I../../bfd 
> -I/home/jsun/work/buildroot/snapshot-051122/buildroot/toolchai
> n_build_arm_nofpu/gdb-6.3/gdb/gdbserver/../../bfd 
> /home/jsun/work/buildroot/snapshot-051122/buildroot/toolchain_
> build_arm_nofpu/gdb-6.3/gdb/gdbserver/gdbreplay.c
> > rm -f gdbreplay
> > 
> /home/jsun/work/buildroot/snapshot-051122/buildroot/build_arm_
> nofpu/staging_dir/bin/arm-linux-uclibc-gcc -Os -pipe    
> -rdynamic -o gdbreplay gdbreplay.o \
> > 
> > gdbreplay.o: In function `logchar':
> > 
> /home/jsun/work/buildroot/snapshot-051122/buildroot/toolchain_
> build_arm_nofpu/gdb-6.3/gdb/gdbserver/gdbreplay.c:185: 
> undefined reference to `__fgetc_unlocked'
> > 
> /home/jsun/work/buildroot/snapshot-051122/buildroot/toolchain_
> build_arm_nofpu/gdb-6.3/gdb/gdbserver/gdbreplay.c:186: 
> undefined reference to `__fputc_unlocked'
> > 
> /home/jsun/work/buildroot/snapshot-051122/buildroot/toolchain_
> build_arm_nofpu/gdb-6.3/gdb/gdbserver/gdbreplay.c:194: 
> undefined reference to `__fgetc_unlocked'
> > 
> /home/jsun/work/buildroot/snapshot-051122/buildroot/toolchain_
> build_arm_nofpu/gdb-6.3/gdb/gdbserver/gdbreplay.c:195: 
> undefined reference to `__fputc_unlocked'
> > 
> /home/jsun/work/buildroot/snapshot-051122/buildroot/toolchain_
> build_arm_nofpu/gdb-6.3/gdb/gdbserver/gdbreplay.c:220: 
> undefined reference to `__fgetc_unlocked'
> > 
> /home/jsun/work/buildroot/snapshot-051122/buildroot/toolchain_
> build_arm_nofpu/gdb-6.3/gdb/gdbserver/gdbreplay.c:221: 
> undefined reference to `__fputc_unlocked'
> > 
> /home/jsun/work/buildroot/snapshot-051122/buildroot/toolchain_
> build_arm_nofpu/gdb-6.3/gdb/gdbserver/gdbreplay.c:224: 
> undefined reference to `__fgetc_unlocked'
> > 
> /home/jsun/work/buildroot/snapshot-051122/buildroot/toolchain_
> build_arm_nofpu/gdb-6.3/gdb/gdbserver/gdbreplay.c:225: 
> undefined reference to `__fputc_unlocked'
> > collect2: ld returned 1 exit status
> > make[1]: *** [gdbreplay] Error 1
> > make[1]: Leaving directory 
> `/home/jsun/work/buildroot/snapshot-051122/buildroot/build_arm
> _nofpu/gdbserver-6.3'
> > make: *** 
> [/home/jsun/work/buildroot/snapshot-051122/buildroot/build_arm
> _nofpu/gdbserver-6.3/gdbserver] Error 2
> > 
> > _______________________________________________
> > uClibc mailing list
> > uClibc at uclibc.org
> > http://busybox.net/cgi-bin/mailman/listinfo/uclibc
> _______________________________________________
> uClibc mailing list
> uClibc at uclibc.org
> http://busybox.net/cgi-bin/mailman/listinfo/uclibc
> 
> 



More information about the uClibc mailing list