delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/12/02/05:13:50

Date: Wed, 2 Dec 1998 10:50:24 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Arthur <arfa AT clara DOT net>
cc: DJGPP Mailing List <djgpp AT delorie DOT com>
Subject: RE: gcc and g++ problem
In-Reply-To: <199812011753.RAA24685@remus.clara.net>
Message-ID: <Pine.SUN.3.91.981202105002.24125J-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com

On Tue, 1 Dec 1998, Arthur wrote:

> Then why can I compile a file with the .cc or .cpp extension using gxx but
> not with gcc? It doesn't work on my system, not unless I specify that my
> file has to link with -lstdcxx.

You are mixing compilation with linking.  Linking C++ programs without
explicitly mentioning -lstdcxx on the command line is indeed
impossible with gcc, whereas gxx does that for you.

But the source file name extension has nothing to do with that: GCC
only looks at the file name extension when it decides which programs
to invoke (it calls cc1.exe for .c, cc1plus.exe for .cc or .cpp, etc.;
see section 8.4 of the FAQ for the details).  GCC does NOT consult the
file name extension when passing names of the libraries to search to
the linker.

What gxx does is just add -lstdcxx to the libraries it passes to the
linker, no matter which language the sources are.

> the Zip Picker said use gxx and that's what I've been doing
> for the past eight months or so that I've been using DJGPP.

The Zip Picker isn't wrong, since every program needs eventually to be
linked, and it is simpler to tell people to use a single program (gxx)
rather than verbosely explain what I wrote above.  But the truth is
that gxx is *required* only for linking; compilation can be done by
gcc as well.

Now, if you cannot *compile* a C++ programs with "gcc -c foo.cc", then
please report that, since that *should* work.

- Raw text -


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