Mail Archives: djgpp/1996/03/19/09:09:21
On 17 Mar 1996, James N. Domingue wrote:
> When I try to run this simple program:
> #include <iostream.h>
>
> main()
> {
> cout << "Well, hi there.\n" ;
> return 0;
> }
> I get the compiler error messges "undefined reference to 'cout'
> "undefined reference to 'ostream:operator <<(char const *)'"
The best way to avoid these errors is to use `gxx' instead of `gcc' to
compile and link C++ programs. The reason of your problem is that `gcc'
doesn't by default instruct the linker to scan the C++ class libraries
which define `cout' and other C++ functions. You need to append -lgpp
-lstdcxx to the end of your gcc command line to tell gcc about these C++
libraries. When you use `gxx', it does that for you, so you don't have to
remember.
And please be sure to search the DJGPP FAQ list (available as
v2/faq200b.zip from the same place you got DJGPP) for any problem you
have, before you post here. The above problem is explained in section
8.7 of the FAQ.
- Raw text -