Linking error with DINTEGER_ONLY

Jeff Johnston jjohnstn@redhat.com
Wed Feb 1 18:11:00 GMT 2006


Alex Gonzalez wrote:
> Hi,
> 
> If I add DINTEGER_ONLY to CFLAGS_FOR_TARGET, as follows
> 
> CFLAGS_FOR_TARGET = -O2 $(CFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET) -DINTEGER_ONLY
> 
> I get the following error,
> 
> /opt/redhat/mips64linux-031001/H-i686-pc-linux-gnulibc2.2/bin/mips64-linux-gnu-gcc
>  obj/start.o obj/pvmain.o -Llib -EB -N -G0 -nostdlib -static
> -Wl,-Ttext=0x81000000 -Wl,-Map,pv1000_p1.map -lpvos -lpveth
> -L../../libc/trunk/build/mips64-elf/lib/  -L../../pub/lib
> -L../../libc/trunk/mips64-elf/lib -lg -lgcc -lg -lpv1000 -lpvos -o
> pv1000_p1.elf
> ../../libc/trunk/mips64-elf/lib/libg.a(fprintf.o): In function `fprintf':
> /tftpboot/pv-rootfs/usr/src/repository/pktvsn/libc/trunk/build/mips64-elf/newlib/libc/stdio/../../../../../src/newlib/libc/stdio/fprintf.c:45:
> undefined reference to `vfprintf'
> ../../libc/trunk/mips64-elf/lib/libg.a(sprintf.o): In function `_sprintf_r':
> /tftpboot/pv-rootfs/usr/src/repository/pktvsn/libc/trunk/build/mips64-elf/newlib/libc/stdio/../../../../../src/newlib/libc/stdio/sprintf.c:347:
> undefined reference to `_vfprintf_r'
> ../../libc/trunk/mips64-elf/lib/libg.a(sprintf.o): In function `sprintf':
> /tftpboot/pv-rootfs/usr/src/repository/pktvsn/libc/trunk/build/mips64-elf/newlib/libc/stdio/../../../../../src/newlib/libc/stdio/sprintf.c:380:
> undefined reference to `_vfprintf_r'
> collect2: ld returned 1 exit status
> make: *** [pv1000_p1] Error 1
> 
> The linking works OK without the -DINTEGER_ONLY flag.
> 
> I am missing something?
> 

Internally, newlib compiles vfprintf.c and vfscanf.c more than once, 
with and without the -DINTEGER_ONLY flag.  The flag is used to generate 
_vfiprintf_r used by the iprintf family of routines.  When you set this 
flag on, you prevented newlib from building _vfprintf_r which is why you 
got the errors above.  There is a separate flag (-DNO_FLOAT) which is 
used to turn off floating-point support in the printf/scanf family if 
that is what you were trying to do.  You should do this via 
configuration (--disable-newlib-io-float).

-- Jeff J.

> Using,
> 
>  mips64-linux-gnu-gcc (GCC) 3.3-mips64linux-031001
>  Copyright (C) 2002 Free Software Foundation, Inc.
>  This is free software; see the source for copying conditions.  There is NO
>  warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> 
>  and newlib 1.14.0 configured with
> 
>  ../src/configure --host=i686-pc-linux-gnulibc2.2 --target=mips64-elf
> --prefix=../../



More information about the Newlib mailing list