tutorials.neonphog.com icon

c++ - Intro

Getting g++ Making Sure it Runs Next Up

Getting g++

If you are planning on using a compiler other than g++, you may skip this tutorial, moving on to Hello World.

G++ is a part of the Gnu Compiler Collection (GCC), g++ being the c++ compiler.

Linux

If you are using Linux, there is a good chance you already have g++. Skip down to Making Sure it Runs to check. Otherwise you will have to download a package for your distribution. Building from source, in this case, isn't really an option, since you don't seem to have a compiler.

Windows

If you are using Windows, I would recommend downloading and installing MinGW (Minimalist GNU for Windows). Follow the downloads link to their SourceForge site, and get the "Automated MinGW Installer". Be sure to check "g++" and "make" as install options.

You will probably want to add the executables directory to you PATH, so you can run them directly. Right-click on "My Computer", go to "properties", and then the "Advanced" tab. Click on "Environment Variables" and edit the "PATH" variable, adding "C:\MinGW\bin" (substitute the path if you installed it elsewhere) to the list, separated by a semi-colon (;).

Making Sure it Runs

If you have never used the command-line on windows, you can get to it by finding it in your start menu, or "Start", "Run...", and typing in "cmd".

Enter the following at your command prompt:

g++ -v

You should see something like the following:

$ g++ -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.3.2/configure --prefix=/usr --libexecdir=/usr/lib --en
able-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --
enable-languages=c,c++ --disable-bootstrap
Thread model: posix
gcc version 4.3.2 (GCC)
$

If you get an error about command not found, either the compiler is not on your system, or your shell cannot find it. Please go back to Getting g++.

Next Up

Next, we will create an actual Hello World source file, and compile an executable.

tutorials home c++ home