This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: trying to compile
- To: "'Grosu, Yair'" <Yair_Grosu at icomverse dot com>
- Subject: RE: trying to compile
- From: "Rupert Wood" <me at rupey dot net>
- Date: Fri, 12 Oct 2001 08:51:37 +0100
- Cc: <gcc-help at gcc dot gnu dot org>
Yair Grosu wrote:
> I am new with GCC and Linux. I am trying to compile and link a
> program and do not manage to link it since I do not know how to
> specify for it the location of the directory where the iostream
> (cout/cin) library is located.
Hmm - I tried to answer this yesterday and didn't manage too well :-)
You shouldn't have to specify the location: the compiler driver will do
that for you. Assuming, that is, you're using the correct compiler
driver. You should compile and link C++ code with 'g++' and not with
'gcc'.
This is probably the error you're getting:
fox:~$ cat test.C
#include <iostream>
int main()
{
int i;
std::cin >> i;
std::cout << i;
return i;
}
fox:~$ gcc test.C
Undefined first referenced
symbol in file
cout /var/tmp/ccf6PsmP.o
istream::operator>>(int &) /var/tmp/ccf6PsmP.o
ostream::operator<<(int) /var/tmp/ccf6PsmP.o
cin /var/tmp/ccf6PsmP.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status
fox:~$
But if you build with g++ instead of gcc, it links correctly:
fox:~$ g++ test.C
fox:~$
Rup.