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

2 Answers 2

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 V
    Jun 16, 2015 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. Jun 16, 2015 at 23:29
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 V
    Jun 22, 2015 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, 2015 at 1:50

You must log in to answer this question.

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