public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Forcing gcc to compile c++ programs...?
@ 2003-09-15 19:49 Justin Miller
  2003-09-15 19:58 ` Eljay Love-Jensen
  0 siblings, 1 reply; 9+ messages in thread
From: Justin Miller @ 2003-09-15 19:49 UTC (permalink / raw)
  To: gcc-help

How can I force gcc to compile a c/c++ program that has a c-style
extension w/o changing that extension??

Justin Miller

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

* Re: Forcing gcc to compile c++ programs...?
  2003-09-15 19:49 Forcing gcc to compile c++ programs...? Justin Miller
@ 2003-09-15 19:58 ` Eljay Love-Jensen
  2003-09-15 20:05   ` Justin Miller
  0 siblings, 1 reply; 9+ messages in thread
From: Eljay Love-Jensen @ 2003-09-15 19:58 UTC (permalink / raw)
  To: Justin Miller, gcc-help

Hi Justin,

For instance:
gcc -x c++ foo.whatever

--Eljay


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

* Re: Forcing gcc to compile c++ programs...?
  2003-09-15 19:58 ` Eljay Love-Jensen
@ 2003-09-15 20:05   ` Justin Miller
  2003-09-15 20:09     ` Eljay Love-Jensen
  0 siblings, 1 reply; 9+ messages in thread
From: Justin Miller @ 2003-09-15 20:05 UTC (permalink / raw)
  To: Eljay Love-Jensen; +Cc: gcc-help

Ok, that seemed to allow it to compile, but not to link. These are just
a sample of the errors I'm getting. Any clue??

Justin

/tmp/ccBFO83w.o(.text+0x22): In function `main':
: undefined reference to `std::allocator<char>::allocator[in-charge]()'
/tmp/ccBFO83w.o(.text+0x3d): In function `main':
: undefined reference to `std::basic_string<char,
std::char_traits<char>, std::allocator<char>
>::basic_string[in-charge](char const*, std::allocator<char> const&)'
/tmp/ccBFO83w.o(.text+0x5d): In function `main':
: undefined reference to `std::allocator<char>::~allocator
[in-charge]()'

On Mon, 2003-09-15 at 15:58, Eljay Love-Jensen wrote:
> Hi Justin,
> 
> For instance:
> gcc -x c++ foo.whatever
> 
> --Eljay
> 
> 

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

* Re: Forcing gcc to compile c++ programs...?
  2003-09-15 20:05   ` Justin Miller
@ 2003-09-15 20:09     ` Eljay Love-Jensen
  2003-09-15 20:28       ` Justin Miller
  0 siblings, 1 reply; 9+ messages in thread
From: Eljay Love-Jensen @ 2003-09-15 20:09 UTC (permalink / raw)
  To: Justin Miller; +Cc: gcc-help

Hi Justin,

It looks like your C++ file isn't C++ compliant.

Does it have...

#include <string>
using std::string;

...or...

#include <string>
using namespace std;

...near the top?

--Eljay


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

* Re: Forcing gcc to compile c++ programs...?
  2003-09-15 20:09     ` Eljay Love-Jensen
@ 2003-09-15 20:28       ` Justin Miller
  2003-09-15 20:31         ` Eljay Love-Jensen
  0 siblings, 1 reply; 9+ messages in thread
From: Justin Miller @ 2003-09-15 20:28 UTC (permalink / raw)
  To: Eljay Love-Jensen; +Cc: gcc-help

On Mon, 2003-09-15 at 16:08, Eljay Love-Jensen wrote:

> #include <string>
> using namespace std;
> 
> ...near the top?

Yes, it indeed does have this.

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

* Re: Forcing gcc to compile c++ programs...?
  2003-09-15 20:28       ` Justin Miller
@ 2003-09-15 20:31         ` Eljay Love-Jensen
  2003-09-15 20:35           ` Justin Miller
  0 siblings, 1 reply; 9+ messages in thread
From: Eljay Love-Jensen @ 2003-09-15 20:31 UTC (permalink / raw)
  To: Justin Miller; +Cc: gcc-help

Hi Justin,

If it's a C++ program, are you using 'g++' instead of 'gcc'?

The 'g++' one includes all the C++ related stuff for linking, whereas 'gcc' does not.  If you wanted to use 'gcc' you have to include the C++ stuff explicitly.

--Eljay


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

* Re: Forcing gcc to compile c++ programs...?
  2003-09-15 20:31         ` Eljay Love-Jensen
@ 2003-09-15 20:35           ` Justin Miller
  2003-09-15 21:15             ` Eljay Love-Jensen
  0 siblings, 1 reply; 9+ messages in thread
From: Justin Miller @ 2003-09-15 20:35 UTC (permalink / raw)
  To: Eljay Love-Jensen; +Cc: gcc-help

Yeah, I think I'm being required to use gcc, not g++. What would I need
to explicitly include in order to use gcc?

Justin

On Mon, 2003-09-15 at 16:31, Eljay Love-Jensen wrote:
> Hi Justin,
> 
> If it's a C++ program, are you using 'g++' instead of 'gcc'?
> 
> The 'g++' one includes all the C++ related stuff for linking, whereas 'gcc' does not.  If you wanted to use 'gcc' you have to include the C++ stuff explicitly.
> 
> --Eljay
> 
> 

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

* Re: Forcing gcc to compile c++ programs...?
  2003-09-15 20:35           ` Justin Miller
@ 2003-09-15 21:15             ` Eljay Love-Jensen
  0 siblings, 0 replies; 9+ messages in thread
From: Eljay Love-Jensen @ 2003-09-15 21:15 UTC (permalink / raw)
  To: Justin Miller; +Cc: gcc-help

Hi Justin,

That can vary depending on platform.

On my platform the g++...

g++ foo.cpp

...is equivalent to the gcc...

gcc -nostdlib -x c++ foo.cpp -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc crtend.o crtn.o

Likely, this will vary from platform to platform.

--Eljay


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

* RE: Forcing gcc to compile c++ programs...?
@ 2003-09-15 21:17 lrtaylor
  0 siblings, 0 replies; 9+ messages in thread
From: lrtaylor @ 2003-09-15 21:17 UTC (permalink / raw)
  To: millerj; +Cc: gcc-help

Justin,

You _may_ also get by simply by linking to the standard C++ library (that's where the symbols it was complaining about are defined): -lstdc++.

Thanks,
Lyle Taylor

-----Original Message-----
From: Eljay Love-Jensen [mailto:eljay@adobe.com]
Sent: Monday, September 15, 2003 3:15 PM
To: Justin Miller
Cc: gcc-help@gcc.gnu.org
Subject: Re: Forcing gcc to compile c++ programs...?

Hi Justin,

That can vary depending on platform.

On my platform the g++...

g++ foo.cpp

...is equivalent to the gcc...

gcc -nostdlib -x c++ foo.cpp -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc crtend.o crtn.o

Likely, this will vary from platform to platform.

--Eljay

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

end of thread, other threads:[~2003-09-15 21:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-15 19:49 Forcing gcc to compile c++ programs...? Justin Miller
2003-09-15 19:58 ` Eljay Love-Jensen
2003-09-15 20:05   ` Justin Miller
2003-09-15 20:09     ` Eljay Love-Jensen
2003-09-15 20:28       ` Justin Miller
2003-09-15 20:31         ` Eljay Love-Jensen
2003-09-15 20:35           ` Justin Miller
2003-09-15 21:15             ` Eljay Love-Jensen
2003-09-15 21:17 lrtaylor

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).