www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/03/19/09:09:21

Date: Tue, 19 Mar 1996 15:59:57 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: "James N. Domingue" <76162 DOT 3324 AT compuserve DOT com>
Cc: gcc gurus <djgpp AT sun DOT soe DOT clarkson DOT edu>
Subject: Re: djgpp
In-Reply-To: <960317152140_76162.3324_GHM45-1@CompuServe.COM>
Message-Id: <Pine.SUN.3.91.960319155417.20848A-100000@is>
Mime-Version: 1.0

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019