delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/01/21:56:52

From: Fremlin (John, Maria, Peter or David) <fremlin AT oncology DOT wisc DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Undefined cout?
Date: Tue, 1 Apr 97 18:12:40 CST
Organization: University of Wisconsin, Madison
Lines: 87
Message-ID: <76353.fremlin@oncology.wisc.edu>
Reply-To: <fremdh AT essex DOT ac DOT uk>
NNTP-Posting-Host: f209-134.net.wisc.edu
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On Tue, 1 Apr 1997 11:54:47 +0800, 
John Wong  <johnw AT ecs DOT school DOT net DOT hk> 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.
>
>
>John
>

The error messages are presumably from the link process (compilation 
gives line numbers) so it seems that you haven't linked in the 
stream library, libiostr.a. 
Check that you have this file - it should be in your djgpp/lib 
directory. If you have it then you can link it in with -liostr
on the gcc command line.
If you do not have libiostr.a then you have an incomplete installation.
Check you have these files 
(any simtel mirror, /gnu/djgpp/v2/README.1ST):

[snip]

To build C programs, you'll need djdev201.zip, gcc2721b.zip, and

bnu27b.zip.  For C++, also get gpp2721b.zip and lgp271b.zip.  To read

the online manuals, get txi390b.zip and run "info".

[snip]

For more

details, download faq210b.zip (the full FAQ list) and read Chapter 4

there.

[snip]

I suggest you use the RHIDE editor. It certainly helped me as
a beginnner (http://www.tu-chemnitz.de/~rho/rhide.html or any 
simtel mirror /gnu/djgpp/v2apps/rhide11b.zip).

I don't see anything wrong with your code.






John Fremlin
(fremdh AT essex DOT ac DOT uk)

Do not be too proud to help.

- Raw text -


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