On Wed, Mar 01, 2000 at 12:22:09PM -0700, John Starkey wrote:
> I'm not sure if I am out of the scope of this list yet, but since I'm
> still new to Linux and gcc I thought I'd ask you guys.
> 
> RedHat6.1 is the system.
> 
> I'm trying to compile a small assignment for school using gcc. It won't
> compile so I stripped it down to "Hello World". I thought I'd compiled
> on this machine before but maybe not. Anyway.
from the references to endl and cout and << below, I'm guessing this is
c++ you are writing?

You'll need to invoke the compiler as g++ not gcc:

Script started, file is typescript
[noop@reilly]$cat file.cpp 
#include <iostream.h>

int main (void){
        cout << "Hello World!\n"<<endl;
}
[noop@reilly]$gcc -o file file.cpp 
/tmp/ccZRcQYq.o: In function `main':
/tmp/ccZRcQYq.o(.text+0xa): undefined reference to `endl(ostream &)'
/tmp/ccZRcQYq.o(.text+0x17): undefined reference to `cout'
/tmp/ccZRcQYq.o(.text+0x1c): undefined reference to `ostream::operator<<(char const *)'
/tmp/ccZRcQYq.o(.text+0x27): undefined reference to `ostream::operator<<(ostream 
&(*)(ostream &))'
collect2: ld returned 1 exit status
[noop@reilly]$g++ -o file file.cpp 
[noop@reilly]$./file 
Hello World!
        
[noop@reilly]$exit
exit
Script done, file is typescript


This should solve it. I believe g++ invokes ld (the linker) with different
options which let it deal with c++ name-mangling...

have fun

greg
-- 
this is not here

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to [EMAIL PROTECTED]
Please read the FAQ at http://www.linux-learn.org/faqs

Reply via email to