2

I run Ubuntu 13.04 (x86_64 if it matters) which I recently installed. Before, when using 12.10, I had both gcc and g++ from the beginning. However, with 13.04 after I downloaded gcc-4.8.1 sources I found out I was not able to build it due to lack of a C++ compiler. I tried g++ in console and it said the program was not installed. gcc -v shows c++ among other languages in --enable-languages.

So, the question basically is: how come gcc package does not contain the C++ compiler (g++)? I know (well, at least I guess) I can install it by running

sudo apt-get intall g++

but I wonder if I can somehow make my pre-installed gcc package work. Maybe linking gcc to g++ or something? I am pretty sure with Ubuntu 12.10 I had g++ from the beginning.

4
  • 2
    Why not just install build-essential? It will allow you to make all this work without any other hassle. Also, gcc is the C compiler not the C++ compiler, so you have to use g++ for C++
    – Thomas Ward
    Jul 23, 2013 at 20:09
  • Read What is the difference between g++ and gcc?. It clarifies why g++ depends on gcc and not backwards.
    – edwin
    Jul 24, 2013 at 0:04
  • Yes but gcc (standing for GNU Compiler Collection) should contain c++ compiler (g++). In other words, g++ is supposed to be part of gcc package (wiki agrees).
    – Cthulhu
    Jul 24, 2013 at 17:01
  • Yes, but it is not a strict dependency. You can have a C compiler without needing a C++ one. In the end, whether g++ comes with gcc is up to the package maintainers. Notice that not having g++ as a dependency makes of gcc a lighter package to install (not just in download size).
    – edwin
    Jul 26, 2013 at 0:20

1 Answer 1

1

gcc and g++(gcc for C, g++ for C++, etc.) are driver programs(very often they are distributed as seperate packages thus installing one does not guarantee another) which users invoke. They interprets command arguments, calls the actual compiler, runs the assembler on the output, and then optionally runs the linker to produce a complete executable binary.

More read and refs:

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .