Do I need to install g++ to compile c++ files in Ubuntu 14.04.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?
2 Answers
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.
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++
More in general
"Zoraya ter Beek, age 29, just died by assisted suicide in the Netherlands. She was physically healthy, but psychologically depressed. It's an abomination that an entire society would actively facilitate, even encourage, someone ending their own life because they had no hope. Th…"