delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/19/18:04:12

From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Can't get c++ to work
Date: Sun, 19 Oct 1997 16:59:19 +0000
Organization: Two pounds of chaos and a pinch of salt
Lines: 55
Message-ID: <344A3C67.968@cs.com>
References: <344A83E1 DOT DD AT interaxs DOT net>
Reply-To: fighteer AT cs DOT com
NNTP-Posting-Host: ppp206.cs.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Brian Gerwels wrote:
> 
> I've just started using DJGPP.  I've gotten the c compiler to work but
> I'm having trouble with C++.  I've down loaded the files gpp2721b.zip ,
> lgp271b.zip , and obc2721b.zip.
>         When I try to compile a basic "hello c++ world" program (your laugh
> here) I get the errors: undefined reference to 'cout'
>             undefined reference to 'ostream::operator<<(char const *)'
> 
> This is what I type at the command line:
>         gcc hello.cpp

The file 'readme.1st' that comes with DJGPP tells you specifically how
to compile C++ programs.  You can either add '-lgpp' to the end of your
gcc command line, like so:

gcc -o hello.exe hello.cpp -lgpp

Or you can use 'gxx' instead of 'gcc', which adds the C++ libraries for
you:

gxx -o hello.exe hello.cpp

> I've also tried changing the extension to '.cxx'.  I read somthing about

.cxx is not a valid C++ extension.

> using 'G++' at the command line, but I don't have that, I think I've
> downloaded everything I'm suppose to.  I've also tried using gxx and cpp
> at the command prompt but the don't seem to do anything.

cpp is the preprocessor; don't run it manually unless you know what
you're doing.  If you've used gxx and it doesn't work, please consult
chapter 6 of the Frequently Asked Questions list (v2/faq210b.zip from
SimTel or online at http://www.delorie.com/djgpp/v2faq/) for advice.

> I don't think it's a programming mistake but here's the program
> 
> #include <iostream.h>
> void main()

main() must return an integer.  This is one of the rules of C and of
C++.  It's not the cause of your problem, though.  :)

> {
>         cout << "Hello C++ world";
> }

-- 
---------------------------------------------------------------------
|      John M. Aldrich       | "History does not record anywhere at |
|       aka Fighteer I       | any time a religion that has any     |
|   mailto:fighteer AT cs DOT com   | rational basis."                     |
| http://www.cs.com/fighteer |                - Lazarus Long        |
---------------------------------------------------------------------

- Raw text -


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