Command-Line Compilation: Notes

SDK Versions

This is just a place where I keep miscellaneous snippets of information and observations about the compiling and linking process. Consequently, it's not very well structured, and some of the items are incomplete, but maybe it will give you some ideas.

Troubleshooting Checklist

Errors that occur during the linking process are often difficult to understand, partly because the error messages can be misleading.

Environment Variables

My tutories use command line arguments to specify the header and library directories. However, if lots of different libraries are being used, the command line can become unwieldy. Moreover, the scripts/makefiles that rely on these directory names will fail if used on a different computer with different directory structures (e.g. with different versions of the libraries).

These drawbacks can be avoided by using environment variables; cl refers to the environment variable INCLUDE for directories it should search for header files, whilst link refers to LIB for directories containing library files. Environment variables are specific to a computer, so as long as all the libraries needed for the compilation are present, then the compilation and link commands can be free of any mentions of the directories.

So, the command-line options (e.g. \I %INC_VS% and \LIBPATH:%LIB_VS%) in my tutorials could be replaced by the following environment variables.

set INCLUDE="C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\Include";"C:\Program Files (x86)\Windows Kits\8.1\Include\shared";"C:\Program Files (x86)\Windows Kits\8.1\Include\um"
set LIB="C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\Lib";"C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x86"

cl and link will automatically check these environment variables; you don't have to mention them at all when running the programs.

Visual Studio Path

The PATH used by Visual Studio 2012. Generated from the PATH as set in the Visual Studio 2012 Command Prompt. (Other environment variables are set up separately.) The order of these is appear in the VS PATH.
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools C:\Program Files (x86)\Windows Kits\8.0\bin\x86 C:\Program Files (x86)\Microsoft Visual Studio 11.0\Team Tools\Performance Tools C:\Program Files (x86)\HTML Help Workshop C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\VCPackages C:\Windows\Microsoft.NET\Framework\v3.5 C:\Windows\Microsoft.NET\Framework\v4.0.30319 C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\BIN C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ C:\Program Files (x86)\Microsoft Visual Studio 11.0\VSTSDB\Deploy C:\Program Files (x86)\Microsoft SDKs\F#\3.0\Framework\v4.0\ C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow

Visual Studio PathExt


Visual Studio Environment Variables

Sets-up the environment variables used by Visual Studio 2012. Generated from the variables in place in the Visual Studio 2012 Command Prompt. (PATH is set up separately.)
CommonProgramFiles=C:\Program Files\Common Files
DevEnvDir=C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\
ExtensionSdkDir=C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0\ExtensionSDKs
FSHARPINSTALLDIR=C:\Program Files (x86)\Microsoft SDKs\F#\3.0\Framework\v4.0\
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)\Windows Kits\8.0\include\shared;C:\Program Files (x86)\Windows Kits\8.0\include\um;C:\Program Files (x86)\Windows Kits\8.0\include\winrt;
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)\Windows Kits\8.0\lib\win8\um\x86;
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;C:\Program Files (x86)\Windows Kits\8.0\References\CommonConfiguration\Neutral;C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0\ExtensionSDKs\Microsoft.VCLibs\11.0\References\CommonConfiguration\neutral;
ProgramFiles=C:\Program Files
VCINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\
VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio 11.0\
WindowsSdkDir=C:\Program Files (x86)\Windows Kits\8.0\
WindowsSdkDir_35=C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\
WindowsSdkDir_old=C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\

Useful Links

Home About Me
Copyright © Neil Carter

Content last updated: 2015-09-02