public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* BUG: egcs-1.1-mingw32 - gcc -o hello hello.C
@ 1998-10-14 10:16 Earnie Boyd
  1998-10-14 10:41 ` Mumit Khan
  0 siblings, 1 reply; 6+ messages in thread
From: Earnie Boyd @ 1998-10-14 10:16 UTC (permalink / raw)
  To: Mumit; +Cc: gw32

When giving this command with mingw32 version of egcs-1.1 the stdc++
library isn't properly included at the execution of ld.  This is the
only problem with this command.

g++ -o hello hello.C will properly add the library.

==
-                \\||//
-----------o0O0--Earnie--0O0o------------
--        earnie_boyd@yahoo.com        --
-- http://freeyellow.com/members5/gw32 --
--------------ooo0O--O0ooo---------------

PS: Newbie's, you should visit my page.
_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: BUG: egcs-1.1-mingw32 - gcc -o hello hello.C
  1998-10-14 10:16 BUG: egcs-1.1-mingw32 - gcc -o hello hello.C Earnie Boyd
@ 1998-10-14 10:41 ` Mumit Khan
  1998-10-15 21:47   ` Charles Wilson
  0 siblings, 1 reply; 6+ messages in thread
From: Mumit Khan @ 1998-10-14 10:41 UTC (permalink / raw)
  To: Earnie Boyd; +Cc: gw32

On Wed, 14 Oct 1998, Earnie Boyd wrote:

> When giving this command with mingw32 version of egcs-1.1 the stdc++
> library isn't properly included at the execution of ld.  This is the
> only problem with this command.
> 
> g++ -o hello hello.C will properly add the library.
> 

Hi Earnie,

I'm a bit confused ... "gcc" is the C driver, and "g++" or "c++" is the 
C++ driver. "gcc" will not and should not C++ specific libraries, and the 
only correct and portable way to link C++ programs is to use the "c++" or 
"g++" driver. If "gcc" adds C++ specific libraries, it's a bug, not a 
feature.

Correct way to link C++ programs:

  $ c++ -o hello hello.cc

(or alternatively use g++, which is just a link to c++).

However, *knowing* how gcc works, we can use the C driver to link C++
programs:
  
  $ gcc -o hello hello.cc -lstdc++

Note that you probably should not use '.C' for C++ extension, but rather
something that works on all OS/filesystems (Unix, VMS, Win32), such .cc, 
.cxx, etc (I personally dislike the MS-advocated .cpp extension!).

Please let me know if I'm misinterpreting your note.

Regards,
Mumit


-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: BUG: egcs-1.1-mingw32 - gcc -o hello hello.C
  1998-10-14 10:41 ` Mumit Khan
@ 1998-10-15 21:47   ` Charles Wilson
  1998-10-15 21:47     ` Mumit Khan
  0 siblings, 1 reply; 6+ messages in thread
From: Charles Wilson @ 1998-10-15 21:47 UTC (permalink / raw)
  To: Mumit Khan; +Cc: Earnie Boyd, gw32

Mumit Khan wrote:

> On Wed, 14 Oct 1998, Earnie Boyd wrote:
>
> > When giving this command with mingw32 version of egcs-1.1 the stdc++
> > library isn't properly included at the execution of ld.  This is the
> > only problem with this command.
> >
> > g++ -o hello hello.C will properly add the library.
> >
>
> Hi Earnie,
>
> I'm a bit confused ... "gcc" is the C driver, and "g++" or "c++" is the
> C++ driver. "gcc" will not and should not C++ specific libraries, and the
> only correct and portable way to link C++ programs is to use the "c++" or
> "g++" driver. If "gcc" adds C++ specific libraries, it's a bug, not a
> feature.
>
> Correct way to link C++ programs:
>
>   $ c++ -o hello hello.cc
>
> (or alternatively use g++, which is just a link to c++).
>

<snip>

Up until recently, I believe that gcc when called on a c++ source file,
would call g++, and everything would be fine. This broke at gcc 2.8.0 on
HP-UX, so now you have to call g++ explicitly. I don't know the heritage of
egcs, but it could have inherited this behavior, and thus (egcs) gcc does
not helpfully call (egcs) g++ for you.

--Chuck


-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: BUG: egcs-1.1-mingw32 - gcc -o hello hello.C
  1998-10-15 21:47   ` Charles Wilson
@ 1998-10-15 21:47     ` Mumit Khan
  0 siblings, 0 replies; 6+ messages in thread
From: Mumit Khan @ 1998-10-15 21:47 UTC (permalink / raw)
  To: Charles Wilson; +Cc: Earnie Boyd, gw32

On Thu, 15 Oct 1998, Charles Wilson wrote:

> Up until recently, I believe that gcc when called on a c++ source file,
> would call g++, and everything would be fine. This broke at gcc 2.8.0 on
> HP-UX, so now you have to call g++ explicitly. I don't know the heritage of
> egcs, but it could have inherited this behavior, and thus (egcs) gcc does
> not helpfully call (egcs) g++ for you.

If you haven't seen my followup to Earnie's 2nd posting on this, it'll
soon show up on the list and I won't repeat myself. 

I'll summarize quickly: GCC has *always*, and still does, called the C++ 
compiler when it sees certain suffix, and still does. That has nothing to 
do with linking however, and GCC has *never* linked in the C++ runtime if 
invoked as gcc as opposed to g++/c++.

The only difference in gcc-2.8.0 is that g++ no longer links in the
deprecated libg++ automatically. Before 2.8.0, c++ will only link in
libstc++ and g++ will add libg++ in addition to libstdc++. Now, both
c++ and g++ are identical in behaviour.

It is not a bug, and the behaviour remains the same (minus, and possibly
plus, a few bug fixes in how the driver works). Of course, I'm talking
about gcc2 days; g++ 1.x was a different beast altogether.

I do sympathize with folks who misunderstand how the language drivers in 
gcc is supposed to work; the documentation is not at all clear, and I
obviously haven't done anything to improve it.

Any followups to gcc or egcs related mailing lists please.

Regards,
Mumit


-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: BUG: egcs-1.1-mingw32 - gcc -o hello hello.C
@ 1998-10-15  6:06 Earnie Boyd
  1998-10-15  6:06 ` Mumit Khan
  0 siblings, 1 reply; 6+ messages in thread
From: Earnie Boyd @ 1998-10-15  6:06 UTC (permalink / raw)
  To: Mumit Khan; +Cc: gw32

---Mumit Khan <khan@xraylith.wisc.edu> wrote:
>
> On Wed, 14 Oct 1998, Earnie Boyd wrote:
> 
> > When giving this command with mingw32 version of egcs-1.1 the stdc++
> > library isn't properly included at the execution of ld.  This is the
> > only problem with this command.
> > 
> > g++ -o hello hello.C will properly add the library.
> > 
> 
> Hi Earnie,
> 
> I'm a bit confused ... "gcc" is the C driver, and "g++" or "c++" is
the 
> C++ driver. "gcc" will not and should not C++ specific libraries,
and the 
> only correct and portable way to link C++ programs is to use the
"c++" or 
> "g++" driver. If "gcc" adds C++ specific libraries, it's a bug, not a 
> feature.
> 
> Correct way to link C++ programs:
> 
>   $ c++ -o hello hello.cc
> 
> (or alternatively use g++, which is just a link to c++).
> 
> However, *knowing* how gcc works, we can use the C driver to link C++
> programs:
>   
>   $ gcc -o hello hello.cc -lstdc++
> 
> Note that you probably should not use '.C' for C++ extension, but
rather
> something that works on all OS/filesystems (Unix, VMS, Win32), such
.cc, 
> .cxx, etc (I personally dislike the MS-advocated .cpp extension!).
> 
> Please let me know if I'm misinterpreting your note.
> 

According to the documentation for `gcc' in the `Overall Options' node
I can use .C, .cxx, .cpp, or .cc to indicate that the code is C++. 
The only step of the process that is incorrect is in the absence of
the stdc++ library with the link command.  Also I can specify the
switch `-x c++' which will also incorrectly not include the stdc++
library.

Since the documentaion for gcc indicates that C++, as well as other
dialects, is recognized upon file suffix then the appropriate
libraries should be used or the documentation changed to indicate as
you've suggested.

==
-                \\||//
-----------o0O0--Earnie--0O0o------------
--        earnie_boyd@yahoo.com        --
-- http://freeyellow.com/members5/gw32 --
--------------ooo0O--O0ooo---------------

PS: Newbie's, you should visit my page.
_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: BUG: egcs-1.1-mingw32 - gcc -o hello hello.C
  1998-10-15  6:06 Earnie Boyd
@ 1998-10-15  6:06 ` Mumit Khan
  0 siblings, 0 replies; 6+ messages in thread
From: Mumit Khan @ 1998-10-15  6:06 UTC (permalink / raw)
  To: earnie_boyd; +Cc: Mumit Khan, gw32

Earnie Boyd <earnie_boyd@yahoo.com> writes:
> 
> According to the documentation for `gcc' in the `Overall Options' node
> I can use .C, .cxx, .cpp, or .cc to indicate that the code is C++. 
> The only step of the process that is incorrect is in the absence of
> the stdc++ library with the link command.  Also I can specify the
> switch `-x c++' which will also incorrectly not include the stdc++
> library.

You misunderstand the documentation. When the program called "gcc" sees a
.cpp, it calls the C++ compiler (note the difference between compiler and
driver), just as it calls the f77 compiler when it sees .[fF] extensions.

Linking is something altogether different, and linking stdc++ without
being told to automatically when using gcc is simply *wrong* (think 
binding to unneeded shared libraries, unnecessary static data, so on).

also, question of orthogonality.

  $ gcc -c foo.cc		<-- language can be deduced 
  $ gcc -o foo foo.cc		<-- language/runtime can be deduced 
  $ gcc -o foo foo.o		<-- language/runtime can not be deduced 

> Since the documentaion for gcc indicates that C++, as well as other
> dialects, is recognized upon file suffix then the appropriate
> libraries should be used or the documentation changed to indicate as
> you've suggested.

Compiling a language vs linking objects and hence providing the runtime 
required by those set of objects are treated differently in GCC (and
rightly so). 

I agree that the documentation should be clearer in this regard, and spell 
out that it's talking about *compiling* a language. This behaviour is not
likely to change however since it works and works very well.

Of course, I'm always curious as to why someone would want to use gcc to
compile/link C++ programs unless there is a special reason (I have some
for linking, but never for compiling).

Hope this clears it up.  Please see g++ faq for further info on this.

Regards,
Mumit

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1998-10-15 21:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-10-14 10:16 BUG: egcs-1.1-mingw32 - gcc -o hello hello.C Earnie Boyd
1998-10-14 10:41 ` Mumit Khan
1998-10-15 21:47   ` Charles Wilson
1998-10-15 21:47     ` Mumit Khan
1998-10-15  6:06 Earnie Boyd
1998-10-15  6:06 ` Mumit Khan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).