www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/01/04:51:30

From: Joshua Holt <joshuah AT mail DOT gte DOT net>
Newsgroups: comp.os.msdos.djgpp,comp.lang.c++
Subject: Re: Undefined cout?
Date: Mon, 31 Mar 1997 22:52:33 -0800
Organization: GTE Intelligent Network Services, GTE INS
Lines: 43
Message-ID: <3340B0B1.7A62@mail.gte.net>
References: <Pine DOT LNX DOT 3 DOT 93 DOT 970401115203 DOT 12541B-100000 AT ecs DOT school DOT net DOT hk>
NNTP-Posting-Host: cust41.max34.los-angeles.ca.ms.uu.net
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

John Wong wrote:
> 
> I've got a question about DJGPP installation.  Now I've just installed
> DJGPP 2.0, and find the following program doesn't compile:
> 
> #include <iostream.h>
> 
> class X {
>         int val;
> public:
>         X() {val = 0;}
>         X(int i) {val = i;}
>         void func() const { cout << val << '\n'; }
> };
> 
> main()
> {
>         X v1;
>         v1.func();
>         X(3).func();
>         return 0;
> }
> 
> gcc returns the following statements:
> 
> test.cc(.text+0x5e): undefined reference to `cout'
> test.cc(.text+0x63): undefined reference to `ostream::operator<<(int)'
> test.cc(.text+0x6e): undefined reference to `ostream::operator<<(char)'
> 
> It seems to be a problem with g++, since when I replace iostream.h with
> stdio.h and cout with the C-style printf, everything's alright and the
> program runs as expected.
> 
> What's wrong with my g++ installation (or even my code)?  How to install
> DJGPP correctly?
> 
> Any help would be much appreciated.
> 
> JohnTry compiling like this:

gcc test.cc -otest.exe -liostr

That should fix the problem.

- Raw text -


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