ftp.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/04/05/05:45:10

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: making dxe2gen with clio.rice.edu binaries -or- "undefined reference to 'operator'"?
Date: 5 Apr 2002 10:40:48 GMT
Organization: Aachen University of Technology (RWTH)
Lines: 49
Message-ID: <a8juvg$bg5$1@nets3.rz.RWTH-Aachen.DE>
References: <3ca78d87$0$364$9b622d9e AT news DOT freenet DOT de> <a8eoih$m9u$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE> <3cab2f26$0$152$9b622d9e AT news DOT freenet DOT de> <Pine DOT GSO DOT 4 DOT 44 DOT 0204040850130 DOT 10680-100000 AT mozart DOT orchestra DOT cse DOT unsw DOT EDU DOT AU> <3cace922$0$12701$9b622d9e AT news DOT freenet DOT de>
NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de
X-Trace: nets3.rz.RWTH-Aachen.DE 1018003248 11781 (5 Apr 2002 10:40:48 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 5 Apr 2002 10:40:48 GMT
Originator: broeker@
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

deckerben <deckerben AT freenet DOT de> wrote:

> Thanks for the suggestions.
> I pretty much knew about changing the compiler option by hand. But not every
> package is written in C++ and sometimes they are written in both.

That's not a problem.  GCC is clever enough to know how to compile
C and C++ sources, both using the gcc or g++ driver.  The only point where
it *really* makes a difference is the linking stage.  If there are any
C++ objects involved, you will have to use g++ for linking .o files.

That's why the really good makefiles out there (including the default
setup of GNU make) use independent, configurable names for the C++ and
C compilers, like CC and CXX.  CXX will default to $(CC), but you can
override that.  They also have a separate variable, LD, which points
to the command to be used as the linker.  LD=$(CXX) will usually take
care of all your problems.

> I was hoping for a way that DJGPP could see the difference and adapt itself
> 'on-the-fly' as they say.

It can't.  .o files don't bear a stamp that would show whether they
were made by compiling C or C++ files (or Fortran, or Pascal, or
straight from assembly, or ...).

> Some compilers know, for instance, that they should automaticly try a full
> C++ convention with source files that have the .cpp file extension, and an
> ANSI C convention when they end with .c

GCC does that.  But the moment you separate compilation into .o files
and linking, most of those compiles will fail, too.  In GCC, e.g.

	gcc -o myprog.exe myprog.cpp

will work.  But

	gcc -c myprog.cpp
	gcc -o myprog.exe myprog.o


> But my DJGPP installation was trying to compile a C++ file only using
> default C libraries. 

No. It was trying to *link* it using C libraries. There's an important
difference between compilation and linking you're missing.
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -

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