g++ thinks it is a cross compiler..

Peter Kurpis pkurpis@keck.hawaii.edu
Mon May 20 15:20:00 GMT 2002


I am familiar with this problem on Solaris, but it may be the same thing on Linux.

The heuristic for determining whether g++ is a cross-compiler is (unfortunately)
to build a small program with it, and try to run it.  The problem with this
heuristic is that many systems need help to find libstdc++.so.  If this help
is not set up properly, the executable fails (as it cannot find libstdc++.so),
but the failure is (erroneously) interpreted as g++ being a cross-compiler.

The workaround on some systems (e.g. Solaris, possibly Linux) is to provide a runtime
pointer to the directory containing libstdc++.so, e.g.

	setenv LD_LIBRARY_PATH /usr/local/lib

or

	LD_LIBRARY_PATH=/usr/local/lib

depending on what shell you use.

(I sent a better fix to the autoconf list some months ago, but I don't know whether it 
was incorporated (as I'm not a submitter), nor whether there's been a release since.
If anyone can advise me on going about this, I'd like to make the contribution, as
a lot of people get stuck on this issue.)

> Stumbled over the problem when i was to compile mySQL using the latest gcc
> 3.1.
> This is surely due my errors and ignorance and not any bug in gcc.
> Any suggestions?
> 
> Computer is a Athlon MP.
> RH Linux 7.2(?) Kernel 2.4.17
> 
> Some info about my environment and stuff...
> 
> ./config.guess
> i686-pc-linux-gnu
> 
> [root@db gcc-3.1]# /usr/local/gcc3.1/bin/gcc -v
> Reading specs from /usr/local/gcc3.1/lib/gcc-lib/i686-pc-linux-gnu/3.1/specs
> Configured with:
> ./configure --prefix=/usr/local/gcc3.1 --enable-shared --enable-threads=posi
> x --disable-checking
> Thread model: posix
> gcc version 3.1
> 
> [root@db gcc-3.1]# /usr/local/gcc3.1/bin/g++ -v
> Reading specs from /usr/local/gcc3.1/lib/gcc-lib/i686-pc-linux-gnu/3.1/specs
> Configured with:
> ./configure --prefix=/usr/local/gcc3.1 --enable-shared --enable-threads=posi
> x --disable-checking
> Thread model: posix
> gcc version 3.1
> 
> Konfigurera mysql.
> [root@db mysql-3.23.50]# CC=/usr/local/gcc3.1/bin/gcc
> CXX=/usr/local/gcc3.1/bin/g++ ./configure
> creating cache ./config.cache
> checking host system type... i686-pc-linux-gnu
> checking target system type... i686-pc-linux-gnu
> checking build system type... i686-pc-linux-gnu
> checking for a BSD compatible install... /usr/bin/install -c
> checking whether build environment is sane... yes
> checking whether make sets ${MAKE}... yes
> checking for working aclocal... found
> checking for working autoconf... found
> checking for working automake... found
> checking for working autoheader... found
> checking for working makeinfo... found
> checking whether to enable maintainer-specific portions of Makefiles... no
> checking whether build environment is sane... yes
> checking whether make sets ${MAKE}... (cached) yes
> checking for gawk... gawk
> checking for gcc... /usr/local/gcc3.1/bin/gcc
> checking whether the C compiler (/usr/local/gcc3.1/bin/gcc   ) works... yes
> checking whether the C compiler (/usr/local/gcc3.1/bin/gcc   ) is a
> cross-compiler... no
> checking whether we are using GNU C... yes
> checking whether /usr/local/gcc3.1/bin/gcc accepts -g... yes
> checking for c++... /usr/local/gcc3.1/bin/g++
> checking whether the C++ compiler (/usr/local/gcc3.1/bin/g++   ) works...
> yes
> checking whether the C++ compiler (/usr/local/gcc3.1/bin/g++   ) is a
> cross-compiler... yes
> checking whether we are using GNU C++... yes
> checking whether /usr/local/gcc3.1/bin/g++ accepts -g... yes
> checking how to run the C preprocessor... /usr/local/gcc3.1/bin/gcc -E
> checking C Compiler version... /usr/local/gcc3.1/bin/gcc gcc (GCC) 3.1
> 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.
> checking C++ compiler version... /usr/local/gcc3.1/bin/g++ g++ (GCC) 3.1
> 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.
> checking for ranlib... ranlib
> checking for ld used by GCC... /usr/bin/ld
> checking if the linker (/usr/bin/ld) is GNU ld... yes
> checking for BSD-compatible nm... /usr/bin/nm -B
> checking whether ln -s works... yes
> updating cache ./config.cache
> loading cache ./config.cache within ltconfig
> checking for object suffix... o
> checking for executable suffix... no
> checking for /usr/local/gcc3.1/bin/gcc option to produce PIC... -fPIC
> checking if /usr/local/gcc3.1/bin/gcc PIC flag -fPIC works... yes
> checking if /usr/local/gcc3.1/bin/gcc supports -c -o file.o... yes
> checking if /usr/local/gcc3.1/bin/gcc supports -c -o file.lo... yes
> checking if /usr/local/gcc3.1/bin/gcc supports -fno-rtti -fno-exceptions ...
> yes
> checking if /usr/local/gcc3.1/bin/gcc static flag -static works... -static
> checking if the linker (/usr/bin/ld) is GNU ld... yes
> checking whether the linker (/usr/bin/ld) supports shared libraries... yes
> checking command to parse /usr/bin/nm -B output... ok
> checking how to hardcode library paths into programs... immediate
> checking for /usr/bin/ld option to reload object files... -r
> checking dynamic linker characteristics... Linux ld.so
> checking if libtool supports shared libraries... yes
> checking whether to build shared libraries... yes
> checking whether to build static libraries... yes
> checking for objdir... .libs
> creating libtool
> updating cache ./config.cache
> loading cache ./config.cache
> checking for a BSD compatible install... /usr/bin/install -c
> checking for bison... bison -y
> checking for pdftex... manual.pdf
> checking return type of sprintf... configure: error: can not run test
> program while cross compiling
> 
> 
> 



More information about the Gcc-help mailing list