Configuring Command Line Compilers

(This will enable the compilers permanently so you don't have to do this every time you open a command prompt.)

Overview

Configuring the compilers for GNU and Borland is pretty automatic and done at installation time. Configuring the Microsoft compilers can sometimes be more work.

Under Windows XP, you add/edit environment variables by accessing: My Computer | Properties | Advanced | Environment Variables. If you are using Vista or Windows 7, it should be Computer | Properties | Advanced System Settings | Environment Variables.

You should add these paths to the "User variables". Of course, the paths below assume that you have installed the compiler in the default location on the C drive. If you installed it elsewhere, you'll need to figure out how to modify the paths. Also, each variable and values must be on a single line. I listed them on a separate line for easier reading. For example, the LIBPATH for Visual Studio 2005 should look like this:

LIBPATH=C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\LIB;C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\LIB
You may have to logout and login again for the changes to be completed. Realize, of course, that there are other ways to achieve the end result. This method is one way that I know has worked.

To compile from the command line using Microsoft's 11.0 compiler. (Visual Studio 2012)

INCLUDE=
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE;
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\ATLMFC\INCLUDE;
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\include;

LIB=
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\LIB;
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\ATLMFC\LIB;
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\lib;

LIBPATH=
C:\Windows\Microsoft.NET\Framework\v4.0.30319;
C:\Windows\Microsoft.NET\Framework\v3.5;
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\LIB;
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\ATLMFC\LIB;

PATH=
%PATH%;
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VSTSDB\Deploy;
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE;
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\BIN;
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools;
C:\Windows\Microsoft.NET\Framework\v4.0.30319;
C:\Windows\Microsoft.NET\Framework\v3.5;
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\VCPackages;
C:\Program Files (x86)\HTML Help Workshop;
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Team Tools\Performance Tools;
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\bin;
If you don't want to make these modifications to your system permanent, you can just type this command in a command window (assuming you installed VS to the default location):
"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\BIN\vcvars32.bat"
This will set the enviroment for that command window only. The changes will be discarded when you close the command window.

To compile from the command line using Microsoft's 10.0 compiler. (Visual Studio 2010)

In order to use Microsoft's command line compiler, you must configure at least four environment variables. The four variables are listed below:
INCLUDE=
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE;
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE;
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include;

LIB=
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\LIB;
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\ATLMFC\LIB;
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib;

LIBPATH=
C:\Windows\Microsoft.NET\Framework\v4.0.30319;
C:\Windows\Microsoft.NET\Framework\v3.5;
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\LIB;
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\ATLMFC\LIB;

PATH=
%PATH%;
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VSTSDB\Deploy;
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE;
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN;
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools;
C:\Windows\Microsoft.NET\Framework\v4.0.30319;
C:\Windows\Microsoft.NET\Framework\v3.5;
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\VCPackages;
C:\Program Files (x86)\HTML Help Workshop;
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Performance Tools;
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools;
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin;
You may also need to add these environment variables:
DevEnvDir=C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\
Framework35Version=v3.5
FrameworkDir=C:\Windows\Microsoft.NET\Framework\
FrameworkDIR32=C:\Windows\Microsoft.NET\Framework\
FrameworkVersion=v4.0.30319
FrameworkVersion32=v4.0.30319
If you don't want to make these modifications to your system permanent, you can just type this command in a command window (assuming you installed VS to the default location):
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\vcvars32.bat"
This will set the enviroment for that command window only. The changes will be discarded when you close the command window.

To compile from the command line using Microsoft's 9.0 compiler. (Visual Studio 2008)

In order to use Microsoft's command line compiler, you must configure at least four environment variables. The four variables are listed below:
INCLUDE=
C:\Program Files\Microsoft Visual Studio 9.0\VC\ATLMFC\INCLUDE;
C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE;
C:\Program Files\Microsoft SDKs\Windows\v6.0A\include

LIB=
C:\Program Files\Microsoft Visual Studio 9.0\VC\ATLMFC\LIB;
C:\Program Files\Microsoft Visual Studio 9.0\VC\LIB;
C:\Program Files\Microsoft SDKs\Windows\v6.0A\lib

LIBPATH=
C:\WINDOWS\Microsoft.NET\Framework\v3.5;
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;
C:\Program Files\Microsoft Visual Studio 9.0\VC\ATLMFC\LIB;
C:\Program Files\Microsoft Visual Studio 9.0\VC\LIB

PATH=
%PATH%;
C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE;
C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN;
C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools;
C:\WINDOWS\Microsoft.NET\Framework\v3.5;
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;
C:\Program Files\Microsoft Visual Studio 9.0\VC\VCPackages;
C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin
If you don't want to make these modifications to your system permanent, you can just type this command in a command window (assuming you installed VS to the default location):
"C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat"
This will set the enviroment for that command window only. The changes will be discarded when you close the command window.

To compile from the command line using Microsoft's 8.0 compiler. (Visual Studio 2005)

In order to use Microsoft's command line compiler, you must configure at least four environment variables. The four variables are listed below:
INCLUDE=
C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\INCLUDE;
C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE;
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include;
C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\include;
C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\include

LIB=
C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\LIB;
C:\Program Files\Microsoft Visual Studio 8\VC\LIB;
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib;
C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\lib;
C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Lib

LIBPATH=
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;
C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\LIB

PATH=
%PATH%;
C:\Program Files\Microsoft Visual Studio 8\Common7\IDE;
C:\Program Files\Microsoft Visual Studio 8\VC\BIN;
C:\Program Files\Microsoft Visual Studio 8\Common7\Tools;
C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\bin;
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\bin;
C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\bin;
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;
C:\Program Files\Microsoft Visual Studio 8\VC\VCPackages	
If you don't want to make these modifications to your system permanent, you can just type this command in a command window (assuming you installed VS to the default location):
"C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat"
This will set the enviroment for that command window only. The changes will be discarded when you close the command window.

To compile from the command line using GNU's gcc/g++ compiler.

After installing all of the programs from the Cygwin CD, you simply have to add one directory to your path. Assuming you installed the Cygwin utilities in C:\cygwin\bin, you would simply add it to your path. (Put it first):
PATH=C:\cygwin\bin; ... the rest of the path is here ...
Update: If you are using the GNU compilers from the Cygwin 2012 CD that I distributed, you will need to do a little bit extra. This CD comes with two versions (3.4.4 and 4.5.3) of the GNU compilers and the files are named gcc-3.exe and gcc-4.exe, respectively. (There is no file named gcc.exe or g++.exe because of this.) There are also two versions of g++ (g++-3.exe and g++-4.exe)

If you want to set it up so that under Windows you just type gcc or g++ to run the compilers, you should make copies of the compilers you want to use. For example, if you want to make version 4.3.2 the default compiler, do this:

  1. Open a command window in C:\cygwin\bin (or where ever you installed Cygwin)
  2. Copy gcc-4.exe to gcc.exe like this:
    copy gcc-4.exe gcc.exe
    For g++ it's this (with the double quotes):
    copy "g++-4.exe" "g++.exe"
You should now be able to type gcc or g++ from any command window and get version 4.5.3. If you want to make version 3.4.4 the default, just replace version 4 with version 3 in the copy commands above.

Note: If you are using the recommended Windows-friendly version of Doxygen (not from Cygwin), make sure that the directory for that version comes before the Cygwin bin directory in the PATH. You should just put the Doxygen directory first in the PATH.

To compile from the command line using Borland's 5.82 compiler (Turbo C++)

There are no additional steps required. If you install Turbo C++, the command line compiler is automatically setup for you. (You may have to logout and log back in for the changes to be set.)


Thank you, drive through...