delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/06/26/06:02:14

From: bd733 AT rgfn DOT epcc DOT edu (Jason M. Daniels)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: undefined ref to 'cout'
Date: 25 Jun 1997 16:50:08 GMT
Organization: The Rio Grande Free-Net, El Paso Community College, El Paso, TX
Lines: 43
Message-ID: <5ori80$84e@news.epcc.edu>
References: <Pine DOT GSO DOT 3 DOT 95 DOT 970625015833 DOT 16832A-100000 AT panther DOT Gsu DOT EDU>
NNTP-Posting-Host: rgfn.epcc.edu
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Laura Morris (chelcmx AT panther DOT Gsu DOT EDU) wrote:
> Hello All,

> I just installed DJGPP on my system at home and I've come up with a weird
> error. I tried this simple little program below:

> ---------------------------
> #include <iostream.h>

> void main(void)
> {
>  cout << "hello";
> }
> ----------------------------

> When I tried to compile it (gcc -o output.exe sample.cc) I received the
> following error:

> undefined reference to 'cout'
> undefined reference to 'ostream:operator<<(char const *)'

> I have no idea what this means but I do have lgp271b.zip installed under
> c:\djgpp and iostream.h is in the lang/cxx directory.

> I would appreciate any suggestions. 

If this exact question isn't in the FAQ it should be. The problem is that 
you aren't linking the iostreams library in with your program. You have 
two options:

compile with gxx (fx, gxx sample.cc -o sample.exe) which effectively 
forces your program into the GPL (i think)

link with the stand-alone iostreams library (fx, gcc sample.cc -o 
sample.exe -liostr)

hth!

--
Jason Daniels -- bd733 AT rgfn DOT epcc DOT edu
---> BELIEVE THE LIE <---
Linux: The choice of a GNU generation.
Winblows 95: The world's best-selling computer virus.

- Raw text -


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