• We should now be fully online following an overnight outage. Apologies for any inconvenience, we do not expect there to be any further issues.

What's the difference between gcc and g++ in Linux?

Ameesh

Lifer
Apr 3, 2001
23,686
1
0
g++ calls gcc and uses the c++ linker and calling gcc directly will use the C linker

but dont bother asking what the differences are between the linkers, i know some symbols are named differntly but i dont see how anyone would care bout that

just use gcc


btw: that is what i have heard i make no claims on the accuracy of the above statement
 

JonTheBaller

Golden Member
Dec 2, 2002
1,916
0
0
Originally posted by: Ameesh
g++ calls gcc and uses the c++ linker and calling gcc directly will use the C linker

but dont bother asking what the differences are between the linkers, i know some symbols are named differntly but i dont see how anyone would care bout that

just use gcc

Thanks for the help. Actually for my purposes, g++ worked and gcc didn't. I want to know why. Thanks!
 

Ameesh

Lifer
Apr 3, 2001
23,686
1
0
Originally posted by: johnnytightlips
Originally posted by: Ameesh
g++ calls gcc and uses the c++ linker and calling gcc directly will use the C linker

but dont bother asking what the differences are between the linkers, i know some symbols are named differntly but i dont see how anyone would care bout that

just use gcc

Thanks for the help. Actually for my purposes, g++ worked and gcc didn't. I want to know why. Thanks!

are you using the standard c++ libraries? if so you need to run gcc with the " -x c++ " option to tell gcc to load up the std c++ library
 

Heisenberg

Lifer
Dec 21, 2001
10,621
1
0
Originally posted by: Ameesh
Originally posted by: Heisenberg
gcc is the standard C compiler and g++ is the C++ compiler.

i know you can compile c++ with gcc
I've never tried as I do all my work in fortran and haven't used c for years. I just always think of them that way, although like you said, they just vary by the linker they call.
 

JonTheBaller

Golden Member
Dec 2, 2002
1,916
0
0
Even when I use the -x c++ option I get a ton of linking errors. g++ alone returns none. Is there anything "bad" or "wrong" about using g++?
 

Ameesh

Lifer
Apr 3, 2001
23,686
1
0
Originally posted by: johnnytightlips
Even when I use the -x c++ option I get a ton of linking errors. g++ alone returns none. Is there anything "bad" or "wrong" about using g++?

try

-lstdc++ -lm
 

JonTheBaller

Golden Member
Dec 2, 2002
1,916
0
0
Originally posted by: Ameesh
Originally posted by: johnnytightlips
Even when I use the -x c++ option I get a ton of linking errors. g++ alone returns none. Is there anything "bad" or "wrong" about using g++?

try

-lstdc++ -lm

Hey, what does that do?
 

Ameesh

Lifer
Apr 3, 2001
23,686
1
0
Originally posted by: johnnytightlips
Originally posted by: Ameesh
Originally posted by: johnnytightlips
Even when I use the -x c++ option I get a ton of linking errors. g++ alone returns none. Is there anything "bad" or "wrong" about using g++?

try

-lstdc++ -lm

Hey, what does that do?

did it work?
 

dighn

Lifer
Aug 12, 2001
22,820
4
81
Originally posted by: johnnytightlips
Originally posted by: Ameesh
Originally posted by: johnnytightlips
Even when I use the -x c++ option I get a ton of linking errors. g++ alone returns none. Is there anything "bad" or "wrong" about using g++?

try

-lstdc++ -lm

Hey, what does that do?

links standard c++ library
 

gooch

Member
Oct 11, 1999
199
0
0
Originally posted by: Ameesh
g++ calls gcc and uses the c++ linker and calling gcc directly will use the C linker

but dont bother asking what the differences are between the linkers, i know some symbols are named differntly but i dont see how anyone would care bout that

just use gcc


btw: that is what i have heard i make no claims on the accuracy of the above statement

g++ and gcc use the same linker. The difference is what libraries are brought in at link time. g++ will bring in the standard C++ library and any other library that is dependent. gcc will just do the C libraries. When doing a compilation, pass -v and you will see all the options being passed to the various tools during compilation (pre-processor, compiler, assembler, linker). Try a file with gcc, then with g++ and you will see the differences in the libraries brought in.