skip navigation

www.Hilands.com


Content:: C / C++

C / C++
Last Modified: 2009-09-12
Table of Contents
Compiler
When dealing with a Compiled Language such as C or C++ the first thing we need to do is obtain a compiler. Most linux systems have these compilers built into the base packaged operating system.
Running from a debian net install we can use the apt to grab the compilers we want. # apt-get install gcc
# apt-get install g++
# apt-get install make

On a windows system we can get a free port of the Gnu Compiler Collection (GCC) called MinGW from http://www.mingw.org/. For ease of installation we will download the MinGW-5.1.4.exe installation file. You'll be able to find it in the downloads section from the MinGW site under "Automated MinGW Installer\<Version>.
MiniGW Setup MiniGW Setup
Under the installation options I'd recommend adding the "g++ compiler" I also add the GNU Make Installer.
You may notice during the setup the installation program will go out and download some tarball files that have been gzip for the installation. The install file we downloaded is an installation tool that installs mingw from the internet.
Adding MinGW to the Windows Path variable
We will be using the MinGW compiler via command line, to simplify our lives I recommend setting C:\MinGW\bin to the PATH Environmental Variable in windows.

Opening the System Preferences
The Environmental Variables are stored in the System Properties. Right click on My Computer and select Properties from the context menu.
Environmental Variable
In the System Properties window select the Advanced Tab and click on the Environment Variables button.
Environmental Variable Path
In the Environment Variables window go to the "System variables" section select the Path Variable and click the Edit button.
Setting the Environmental Variable Path
We should now be in the "Edit System Variable" window. You should see "Path" in the Variable name text field. At the end of the Variable value text field add C:\mingw\bin. Notice the path deliminator is a semicolon (;), be sure there is one before your new path entry.
Compiling Software
With the path set we can now use the mingw32-gcc.exe and mingw32-g++.exe anywhere we want. # mingw32-gcc <input filename> -o <output filename>
# mingw32-gcc project.c -o project.exe
References