Fedora – How to fix “skipping incompatible /usr/lib/libc.a”

fedoraglibcmake

I get the following error when I try to build an embedded Linux target on a 64 bit Fedora 16 (Verne):

make[3]: Entering directory `/export/home/git/minerva-5.x/third_party/multifiles'
mips-linux-gnu-gcc -EL -O -D_GNU_SOURCE -Wall -isystem /export/home/git/minerva-5.x/cs_rootfs_1.2.15/cross_rootfs/include   -c -o md5.o md5.c
mips-linux-gnu-gcc -EL -O -D_GNU_SOURCE -Wall -isystem /export/home/git/minerva-5.x/cs_rootfs_1.2.15/cross_rootfs/include   -c -o bitmapfs.o bitmapfs.c
mips-linux-gnu-gcc -EL -O -D_GNU_SOURCE -Wall -isystem /export/home/git/minerva-5.x/cs_rootfs_1.2.15/cross_rootfs/include   -c -o mfcln.o mfcln.c
mips-linux-gnu-gcc -EL -Wl,-rpath /export/home/git/minerva-5.x/cs_rootfs_1.2.15/cross_rootfs/lib -L/export/home/git/minerva-5.x/cs_rootfs_1.2.15/cross_rootfs/lib -o mfcln md5.o bitmapfs.o mfcln.o mulfiles.h mulfiles_msg.h md5.h bitmapfs.h
gcc -O -Wall -m32 -c -o md5_x86_32.o md5.c
gcc -O -Wall -m32 -c -o mfsrv_x86_32.o mfsrv.c
gcc -O -m32 -o mfsrv32 md5_x86_32.o mfsrv_x86_32.o
gcc -O -m32 -static -o mfsrv32-static md5_x86_32.o mfsrv_x86_32.o
gcc -O -Wall -c -o md5_x86_64.o md5.c
gcc -O -Wall -c -o mfsrv_x86_64.o mfsrv.c
gcc -O -o mfsrv64 md5_x86_64.o mfsrv_x86_64.o
gcc -O -static -o mfsrv64-static md5_x86_64.o mfsrv_x86_64.o
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.6.3/../../../libc.a when searching for -lc
/usr/bin/ld: skipping incompatible /usr/lib/libc.a when searching for -lc
/usr/bin/ld: cannot find -lc
collect2: ld returned 1 exit status
make[3]: *** [mfsrv64-static] Error 1

I need to use an older version of make (make381) probably since the kernel is old and customized (2.6.22.19-39-sigma) and the target is MIPS. I have also installed ncurses-static, glibc-static.i686, and glibc-devel.i686 on my system. Do I need a compatible libc.a for make381? If so, Where can I find it? If not, where do I look next to fix this build?

The full console output is here.

Best Answer

make itself has likely not much to do with the problem. The symptoms are typical of using wrong toolchain and/or libraries. The output indicates that the linker in use is the stock Fedora ld, which on 64bit Fedora would mean a toolchain capable of producing x86_64 binaries.

skipping incompatible /usr/lib/libc.a

tells you, that the linker tried linking with /usr/lib/libc.a but found it (binary) incompatible with the rest of the compiled code in md5_x86_64.o and mfsrv_x86_64.o. This typically arises due to an architecture mismatch - in this case it seems that the build system attempts to link a 64bit object files with a 32bit library (note that the same command for 32bit binary with -m32 went through just fine). Thus it seems that the compiler is not getting the right options when linking the 64bit binary. As a first step in debugging you might want to try building manually - i.e. issuing the failing command in the build tree by hand.

What is also rather surprising (at least for me) in your case is this:

mips-linux-gnu-gcc -EL -Wl,-rpath /export/home/git/minerva-5.x/cs_rootfs_1.2.15/cross_rootfs/lib -L/export/home/git/minerva-5.x/cs_rootfs_1.2.15/cross_rootfs/lib -o mfcln md5.o bitmapfs.o mfcln.o mulfiles.h mulfiles_msg.h md5.h bitmapfs.h
gcc -O -Wall -m32 -c -o md5_x86_32.o md5.c

that is: part of the build using the cross toolchain and part using the native one and in both the 64bit and 32bit flavours. Which might be all right, but looks a bit strange.

Related Question