delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/05/24/02:36:35

Date: Wed, 24 May 2000 09:36:00 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Marcelo Juchem <mj-me AT plug-in DOT com DOT br>
cc: "'djgpp AT delorie DOT com'" <djgpp AT delorie DOT com>
Subject: Re: HELP WITH C++ COMPILING: UNDEFINED REFERENCE appears when using functions from IOSTREAM.H
In-Reply-To: <01BFC526.FE13C1C0@mdm122.plug-in.com.br>
Message-ID: <Pine.SUN.3.91.1000524093351.12232A-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Wed, 24 May 2000, Marcelo Juchem wrote:

> 	gcc hiworld.cpp
> 	gcc -lstdcxx hiworld.cpp
> 	gcc -lstdcxx -o2 hiworld.cpp
> 	gcc -lstdcxx -lgpp hiworld.cpp
> 	gcc -lstdcxx -lgpp -o2 hiworld.cpp
> 
> But it didn't worked at all. I tried everything that's in the FAQs and other stuff. All my enviroment files/variables/.../setup/installation are ok. The following output is generated from gcc:
> 
> d:/djgpp/tmp\cckLVI2c.o(.text+0x1b):hiworld.cpp: undefined reference to 'cout'
> d:/djgpp/tmp\cckLVI2c.o(.text+0x1b):hiworld.cpp: undefined reference to 'ostream::operator<<(char const *)'
> collect2: ld returned 1 exit status

Your command line is all wrong.  Try this:

	gcc -O2 hiworld.cpp -o hiworld.exe -lstdcxx

Note the order (-lstdcxx is last), and Capital O in -O2.  Also note the 
"-o hiworld.exe" part.

This is all explained in the FAQ and in the file README.1ST which comes 
with DJGPP.

- Raw text -


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