gcc not for C++?
When writing C++ programs with classes, I get an error with gcc, but g++ and c++ run fine.
[byt83@CPQNiT Task3]$ ls
task1.cpp task2.cpp task3.cpp
[byt83@CPQNiT Task3]$ gcc -lm -o task2 task2.cpp
/tmp/ccF3VOWt.o(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
[byt83@CPQNiT Task3]$ g++ -o task2 task2.cpp
[byt83@CPQNiT Task3]$ c++ -o task2 task2.cpp
Any clues, anybody? In an earlier post, gcc is supposed to be a C compiler and not a C++ compiler, but if that's the case, how would somebody explain this:
[byt83@CPQNiT Task3]$ whatis gcc
gcc (1) - GNU project C and C++ compiler
There is a flag where you can set the language: gcc -x c++ (I believe, though I could be wrong. Check the documentation to be sure.)
gcc will work with either or, but if you are going to use C++ programs, you need to specify the language like above, and also to link against -lstdc++. By calling it as g++, it does all of this for you automatically.
The language specification is unnecessary if the file ends in .cpp, .cxx, .C or .cc, but the linking to the C++ standard library is what causes the errors.
Gcc stands for the GNU Compiler Collection. When you download the Win32 version, for example, you get C, C++, and Fortran 77 (does anybody actually use this part?).