delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/11/30/03:12:52

From: khan AT xraylith DOT wisc DOT edu (Mumit Khan)
Subject: Re: gcc vs g++ bizarre behaviour (newbie - sorry to say)
30 Nov 1998 03:12:52 -0800 :
Message-ID: <199811300547.XAA24357.cygnus.gnu-win32@modi.xraylith.wisc.edu>
References: <3661A825 DOT CECDB92F AT interport DOT net>
To: Allan Peda <allan AT interport DOT net>
Cc: cygwin <gnu-win32 AT cygnus DOT com>

Allan Peda <allan AT interport DOT net> writes:
> 
> I am not having success invoking g++ via gcc.  Rather than describe
> it... take a look:

Then don't! Here's a simple formula that works: Link C programs with
gcc; link C++ programs with c++ or g++ (which are the same thing)
to get the C++ runtime libraries automatically linked in; link f77
programs with g77. 

If you want to do anything else, then you have to figure out the runtime 
libraries needed for each language and provide them yourself. (Hint: C++ 
programs usually need -lstdc++).

> bash-2.02$ ./hellocc
> hello C++ GNUish world!
> bash-2.02$ rm ./hellocc.exe
> bash-2.02$ gcc -x "c++" hellocc.cxx -o hellocc
> C:\TEMP\cccQV0Xf.o(.text+0x2a):hellocc.cc: undefined reference to `cout'
> 
> C:\TEMP\cccQV0Xf.o(.text+0x2f):hellocc.cc: undefined reference to
> `ostream::oper
> ator<<(char const *)'

The above should give you the clue needed. You misunderstand the implication 
of "-x c++" option.

Nothing bizarre here. It's expected and documented behaviour.

Regards,
Mumit

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

- Raw text -


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