g++ error on Solaris/Sparc undefined reference to std::cout

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,
I have built GCC 4.6.0 on Solaris10/SPARC using following
configuration to make the compiled GCC use GNU ld and as.
The GNU ld and as are from GNU binutils downloaded from SUN free
software. ld version is 2.21
The GCC and related libraries (GMP, MPFR, MPC) are installed in
/lab/home/zuoqi/gcc32/gcc-gnu-ccs

#!/bin/sh
LD_LIBRARY_PATH=/lab/home/zuoqi/gcc32/gcc-gnu-ccs/lib
export LD_LIBRARY_PATH
cd /lab/home/zuoqi/gcc32/build-gcc-gnu-ccs
rm -rf *
../gcc-4.6.0/configure ABI=32
--prefix=/lab/home/zuoqi/gcc32/gcc-gnu-ccs --with-gnu-as
--with-as=/usr/local/bin/as --with-gnu-ld --with-ld=/usr/local/bin/ld
--enable-languages=c,c++,java
--with-gmp-include=/lab/home/zuoqi/gcc32/gcc-gnu-ccs/include
--with-gmp-lib=/lab/home/zuoqi/gcc32/gcc-gnu-ccs/lib
--with-mpfr-include=/lab/home/zuoqi/gcc32/gcc-gnu-ccs/include
--with-mpfr-lib=/lab/home/zuoqi/gcc32/gcc-gnu-ccs/lib
--with-mpc-include=/lab/home/zuoqi/gcc32/gcc-gnu-ccs/include
--with-mpc-lib=/lab/home/zuoqi/gcc32/gcc-gnu-ccs/lib --without-ppl
--without-cloog --enable-plugin --enable-lto
make -j 64
make check
make install
echo gcc DONE!

After the buiding was done, I set the LD_LIBRARY_PATH to
/lab/home/zuoqi/gcc32/gcc-gnu-ccs/lib.
There's no problem to compile c programs. However, when I tried to
compile c++ programs with std headers, there were errors related to
undefined reference.

The program is hello.cpp as follow:
#include<iostream>
using namespace std;
int main()
{
	cout << "hello" <<endl;
	return 1;
}

The compile command is : /lab/home/zuoqi/gcc32/gcc-gnu-ccs/bin/g++ hello.cpp

The errors are:
/var/tmp//ccckp3Mi.o: In function `main':
hello.cpp:(.text+0x20): undefined reference to `std::cout'
hello.cpp:(.text+0x24): undefined reference to `std::cout'
hello.cpp:(.text+0x48): undefined reference to
`std::basic_ostream<char, std::char_traits<char>
>::operator<<(std::basic_ostream<char, std::char_traits<char> >&
(*)(std::basic_ostream<char, std::char_traits<char> >&))'
collect2: ld returned 1 exit status

BTW, if I use the default AS and LD path setting for GCC building,
which is /usr/ccs/bin, the as will give following errors. I searched
on the web that the GCC will use the hard-built-in ld first, if there
is any. Then the GCC will use /usr/ccs/bin/as and /usr/ccs/bin/ld even
if the AS and LD enviroment variables are set. So I tried to use GNU
AS and LD in /usr/local/bin while building GCC4.6.0

/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 139: error: unknown
opcode ".weakref"
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 139: error: statement syntax
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 140: error: unknown
opcode ".weakref"
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 140: error: statement syntax
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 141: error: unknown
opcode ".weakref"
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 141: error: statement syntax
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 142: error: unknown
opcode ".weakref"
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 142: error: statement syntax
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 143: error: unknown
opcode ".weakref"
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 143: error: statement syntax
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 144: error: unknown
opcode ".weakref"
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 144: error: statement syntax
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 145: error: unknown
opcode ".weakref"
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 145: error: statement syntax
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 146: error: unknown
opcode ".weakref"
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 146: error: statement syntax
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 147: error: unknown
opcode ".weakref"
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 147: error: statement syntax
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 148: error: unknown
opcode ".weakref"
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 148: error: statement syntax
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 149: error: unknown
opcode ".weakref"
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 149: error: statement syntax
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 150: error: unknown
opcode ".weakref"
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 150: error: statement syntax
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 151: error: unknown
opcode ".weakref"
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 151: error: statement syntax
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 152: error: unknown
opcode ".weakref"
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 152: error: statement syntax
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 153: error: unknown
opcode ".weakref"
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 153: error: statement syntax
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 154: error: unknown
opcode ".weakref"
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 154: error: statement syntax
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 155: error: unknown
opcode ".weakref"
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 155: error: statement syntax
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 156: error: unknown
opcode ".weakref"
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 156: error: statement syntax
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 157: error: unknown
opcode ".weakref"
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 157: error: statement syntax
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 158: error: unknown
opcode ".weakref"
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 158: error: statement syntax
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 159: error: unknown
opcode ".weakref"
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 159: error: statement syntax
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 160: error: unknown
opcode ".weakref"
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 160: error: statement syntax
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 161: error: unknown
opcode ".weakref"
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 161: error: statement syntax
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 162: error: unknown
opcode ".weakref"
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 162: error: statement syntax
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 163: error: unknown
opcode ".weakref"
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 163: error: statement syntax
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 164: error: unknown
opcode ".weakref"
/usr/ccs/bin/as: "/var/tmp//ccsHTDle.s", line 164: error: statement syntax

Would anyone give me some hints about this problem? Thanks a lot!

-- 
Regards
Qi Zuo

School Of Computer Science and Technology
Beijng Institute of Technology, China, 100081


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux