M BUZZ CRAZE NEWS
// general

Do I need to install g++ to compile c++ files in Ubuntu 14.04.1?

By John Parsons

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

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

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

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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