undefined reference to __fgetc_unlocked
Jun Sun
jsun at junsun.net
Wed Nov 23 01:32:17 UTC 2005
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/toolchain_build_arm_nofpu/gdb-6.3/gdb/gdbserver -I/home/jsun/work/buildroot/snapshot-051122/buildroot/toolchain_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/toolchain_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
More information about the uClibc
mailing list