Xref: news2.mv.net comp.os.msdos.djgpp:583 From: a540ami AT pic DOT ucla DOT edu (Ami Fischman) Newsgroups: comp.os.msdos.djgpp Subject: Re: I can't compile C++... Date: 16 Jan 1996 06:39:13 GMT Organization: University of California, Los Angeles Lines: 36 Message-ID: <4dfh6h$h3i@saba.info.ucla.edu> References: <30fb0332 DOT 1350250 AT nntp DOT ix DOT netcom DOT com> NNTP-Posting-Host: venice.pic.ucla.edu To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp In <30fb0332 DOT 1350250 AT nntp DOT ix DOT netcom DOT com>, Danny Yoo (dannyyoo AT ix DOT netcom DOT com) wrote: > Ian Viemeister wrote: > > >>merry way until it started spitting out errors when it saw cin and cout > >>(BTW, I did #include). It didn't give me line numbers for > > > >You have forgotten to add -lgpp to the gcc command line. This tells > >the linker to add in the C++ libs. Please note, this is likely the > >*most* Frequently Asked Question about compiling C++, and it is > >answered in the FAQ (faq102.zip at the DJGPP sites) > > I'm having the same stupid problem, but I AM using > gcc -lgpp [filename], and it still does it. Here's my program and the > output: > > #include "iostream.h" > void main(void) { > cout << "Hello World!\n"; > } > > > test.cc(.text+0x1c): undefined reference to `cout' > test.cc(.text+0x21): undefined reference to `ostream::operator<<(char > const *)' The -lgpp *must* be after the object/source files -- the linker only "remembers" symbols it hasn't resolved yet, so the way you have it, the linker scans libgpp.a, sees cout, figures nobody needs it, and moves on to your program, where you need the symbol... In short, do gcc [filename] -lgpp -- --Ami Have YOU hugged YOUR smurf today? "He's just a politician trying to save both his faces ..."