Tuesday, August 2, 2011

except.c: undefined reference to `libc_name_p'

When cross-compiling GCC 4.5.1 I got this error. Seems to be caused by not having gperf installed:

gperf -o -C -E -k '1-6,$' -j1 -D -N 'libc_name_p' -L ANSI-C \
../../gcc-4.5.1/gcc/cp/cfns.gperf > ../../gcc-4.5.1/gcc/cp/cfns.h
/bin/sh: gperf: command not found
make[1]: *** [../../gcc-4.5.1/gcc/cp/cfns.h] Error 127

Further attempts to compile will find an empty gcc-4.5.1/gcc/cp/cfns.h file and the undefined reference error will be thrown:

cp/except.o: In function `nothrow_libfn_p':
../../gcc-4.5.1/gcc/cp/except.c:***: undefined reference to `libc_name_p'
collect2: ld returned 1 exit status

Solution:
  1. Remove gcc/cp/cfns.h
  2. Install gperf
  3. Run make again to correctly generate the cfns.h file.

No comments:

Post a Comment