1

I am using Ubuntu 14.04.1
I want to know,

Do I need to install g++ from the Ubuntu Software Center to compile the c++ files? Is GCC(GNU Compiler Collection) able to accomplish this instead?

if the answer for my 1st question is, yes...

then, why doesn't Ubuntu 14.04 come with a c++ compiler? After all it is also just as important as GCC? Why will a c++ compiler not ship with a default Ubuntu installation?

0
1

You don't need g++ to compile c++ programs if you have a set of c++ libs. Installed use the proper library flags. Say we want to use gnu's stdc++:

gcc -o target source.cpp -L/usr/lib/architecture & distro dependent/ -lstdc++

and for a long time the guiding people of GNU/Linux where c oriented so until some what recently distros had to package a c compiler with the c++ portions optional. Now I can't say what Ubuntu packages by default since my first command on a new system is often sudo apt-get update && apt-get install g++

2
  • is that c++ libraries comes with default ubuntu installtion or not? – Yuvaraj Jun 22 '15 at 4:59
  • No, not the development versions, you will have to install libstdc++-dev at a minimum. Unless you are bandwidth limited I would suggest going ahead and installing g++ – cargo Jun 23 '15 at 1:50
7

You will need something that can compile C++ files. The two main compilers in Linux are GCC and Clang. GCC is the default compiler in Ubuntu.

GCC isn't installed by default because not everyone needs to compile a file. GCC is typically only used by developers. However, you can easily install it by installing the build-essential package, which is a metapackage that installs gcc (for compiling C files), g++ (for compiling C++ files), and the C library headers.

2
  • if gcc is not installed by default,then how we are using gcc to compile c files in terminal... and i need to know whether the gcc(which is installed by default in ubuntu) is enough to compile c++ files..(because i saw in wikipedia, it is not only gnu c compiler ,it is gnu compiler collection for various languages like c,c++ ..etc) – Yuvaraj Jun 16 '15 at 23:24
  • The program gcc is for compiling C files. GCC as an abbreviation is the GNU Compiler Collection. You need g++ to compile C++ files (try using gcc; you'll get errors). As for the default install of gcc but not g++, I was under the impression neither are installed by default. – saiarcot895 Jun 16 '15 at 23:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.