Date: Wed, 2 Aug 1995 13:31:46 +0300 (IDT) From: Eli Zaretskii To: michael DOT wesolowski AT canada DOT cdev DOT com Cc: djgpp AT sun DOT soe DOT clarkson DOT edu Subject: Re: problems linking C++ On 31 Jul 1995 michael DOT wesolowski AT canada DOT cdev DOT com wrote: > I am attempting to compile a simple 'hello, world' type program > in C++ using DJGPP v 1.12, with all 4 maintenance releases installed. > based upon the verbose output from the compiler, it appears to be > failing during the link phase with the following errors: > > .... undefined reference to cout > ....undefined reference to ostream::operator << (char const *) > Please read the DJGPP FAQ list (available as faq102.zip from the same place you get DJGPP) which says thusly: 8.8 Q: When I compile my program, the linker complains about mathematical functions, although I did #include . Q: The linker complains it cannot find cprintf function. Q: Why do I get so many unresolved symbols when linking C++ programs? A: By default, gcc instructs the linker to only look in two libraries: libgcc.a and libc.a. Some functions aren't included there, so the linker can't find them. For math functions, like sin() and exp(), append ``-lm'' to the gcc command line; for pc-specific functions, like cputs() and cprintf() append ``-lpc''; to use C++ classes append ``-lgpp''. GPL library routines, like obstack and regex packages are in libgpl.a library; append ``-lgpl'' to use them. Note that some C++ classes use math routines, so the -lm should be given after the -lgpp. There are more sections in the FAQ about this issues; I'd recommend you to read them also.