Software build environment setup (Visual Studio 2013)
|Author:||Stefán Örvar Sigmundsson|
|Written in:||English (United Kingdom)|
Microsoft Visual Studio 2013 comes with a number of tools referred to as command prompts. Their purpose is to run compilers, linkers and other programs used in software development targeting the Microsoft Windows operating system as well as .NET Framework. These tools have been a source of confusion for some developers as the terminology used is ambiguous and makes differentiating between them difficult. This article is written with the assumption that Visual Studio 2013 Ultimate is being run on an x86-64 computer under WOW64, but it may apply equally to other versions, editions and architectures as well.
The following terminology must be clearly understood in order to select the appropriate software build environment.
Computers process data in 32-bit or 64-bit units. Support for 16-bit units is still common but undesirable and archaic. Note that some CPUs may be backward compatible, therefore 64-bit computers may process 32-bit and 16-bit data and 32-bit computers may process 16-bit data.
Source code is compiled into instructions that the computer understands. Many instruction sets exist but few are prevalent. The instruction set and CPU design are together called architecture. The latest version of Microsoft Windows runs on 3 architectures. Note that Microsoft may not always use the official architecture names for its products.
|Name||Data size||Microsoft Windows||Also known as|
|IA-32||32-bit||XP, Vista, 7, 8, 8.1||i386, x86|
|x86-64||64-bit||XP, Vista, 7, 8, 8.1||x64, AMD64|
Microsoft offers two flavours of tools called native tools and cross tools. Native tools output for the same architectures as they are being run on and cross tools output for different architectures than those which they are being run on. An example of input could be source code and an example of output could be a binary.
|Input architecture||Output architecture||Tool|
The Microsoft Windows operating system possesses a command-line interpreter called Command Prompt (cmd.exe). It is important to note that the tools provided by Visual Studio 2013 are not actual command-line interpreters but simply shortcuts to Command Prompt. These shortcuts start Command Prompt with pre-defined arguments. The arguments passed to the Command Prompt instance can be seen by right-clicking the shortcuts and selecting Properties. The Target textbox contains the instantiation of Command Prompt (%comspec%) and the arguments passed to it.
The Command Prompt executed by the shortcuts gets passed a batch file (vcvarsall.bat) as an argument and another argument intended for the batch file itself. The purpose of the batch file is to set the necessary environment variables for the Command Prompt session. The only difference between the shortcuts is the argument that gets passed to the batch file. The argument corresponds roughly to the name of the shortcut.
One of the shortcuts is different in that the batch file it runs is called VsDevCmd.bat and it takes no arguments. The environment it sets up is intended for development of software targeting .NET Framework.
|Shortcut||Batch file||Batch argument||Usage|
|Developer Command Prompt for VS2013||VsDevCmd.bat||None||.NET Framework software development|
|VS2013 ARM Cross Tools Command Prompt||vcvarsall.bat||x86_arm||Microsoft Windows software development|
|VS2013 x64 Cross Tools Command Prompt||x86_amd64|
|VS2013 x64 Native Tools Command Prompt||amd64|
|VS2013 x86 Native Tools Command Prompt||x86|
Visual C++ toolset
The Visual C++ toolset is used for software development in both C and C++. The Windows Software Development Kit (SDK) no longer includes the toolset, therefore Visual Studio must be installed in order to obtain it. Microsoft has provided free-of-charge versions of Visual Studio for many years.
The Command Prompt shortcuts provided by Visual Studio 2013 are arbitrary as the software supplies additional environments. All of the environments can be automatically accessed by creating shortcuts for the missing ones or manually by executing the batch file with the relevant argument in Command Prompt. The following is generic code to set up an environment:
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" architecture
The placeholder architecture must be replaced with a valid argument referring to the input/output architecture.
|Input architecture||Output architecture||Argument||Shortcut|
|IA-32, x86-64 (WOW64)||ARMv7||x86_arm||VS2013 ARM Cross Tools Command Prompt|
|IA-32, x86-64 (WOW64)||IA-32||x86||VS2013 x86 Native Tools Command Prompt|
|IA-32, x86-64 (WOW64)||x86-64||x86_amd64||VS2013 x64 Cross Tools Command Prompt|
|x86-64||x86-64||amd64||VS2013 x64 Native Tools Command Prompt|
.NET Framework toolset
Setting up the software build environment for .NET Framework software development is straightforward. Since source code is translated into an intermediate assembly language (called Common Intermediate Language) as opposed to a platform-specific machine language, the compiled output can run on any architecture for which there is an implementation of .NET Framework.
Common Language Runtime (CLR) is the virtual-machine which runs assemblies developed for .NET Framework. Developers can choose to target CLRs running on specific architectures when compiling their source code. This can be necessary when certain components of an assembly rely on other components which are only available on a specific platform. In this context, a platform is a combination of architecture and operating system.
/platform compiler option is used to specifies which version of the CLR can run the particular assembly being compiled. If specified, the option can take a single argument to indicate whether the software being compiled should prefer to run in 32-bit mode on a 64-bit architecture or whether the software being compiled should only run on a particular platform.
|Argument||32-bit architecture||64-bit architecture||Note|
|anycpu||execute if available||execute if available||This argument is the default when the option is not specified.|
|anycpu32bitpreferred||execute if available||execute in 32-bit mode (WOW64)||Only available when targeting .NET Framework 4.5.|
|ARM||execute if available||fails||ARMv7 is a 32-bit architecture. Windows RT was Microsoft's first OS to support ARMv7.|
|Itanium||fails||execute if available||Itanium is a 64-bit architecture. Windows XP was Microsoft's last OS to support Itanium.|
|x64||fails||execute if available||IA-32 can not run 64-bit software.|
|x86||execute if available||execute in 32-bit mode (WOW64)||x86-64 can run 32-bit software using WOW64.|
- Software build environment setup (Visual Studio 2085)
- Software build environment setup (Visual Studio 2088)
- Software build environment setup (Visual Studio 2010)
- Software build environment setup (Visual Studio 2012)
- Software build environment setup (Visual Studio 2015)
- Software build environment setup (Visual Studio 2017)