Partager via


Understanding build environment setttings in Visual Studio IDE vs Command Prompt

As we know, both Visual Studio IDE and its Command Prompt provide build environments to build our C++ applications, but they have some differences. I concluded some features of them as following.

(1)In the VS Command Prompt, if you use "/useenv" switch to launch your VS IDE, then the VS IDE will use the environment variables (PATH, LIB, LIBPATH, INCLUDE, etc) to set the compiler settings (load these environment variables into the VC++Directories), which leads that VS IDE has the same build settings as VS Command Prompt for compiling C++ applications.

(2) VS Command Prompt actually uses a batch script (Common7\Tools\vsvars32.bat) to set the build environment. It is very simple and straightforward. How can you figure it out? Easy. You can right click VS Command Prompt and see its Properties, and then you know it is linked to a batch file. You can trace the batch file to find out the target batch script.

(3) VS IDE (VCBuild) does not really use the batch script file (again, unless you use /useenv). I am not very sure of its internal mechanism. As far as my understanding, its opions (Tools->Options->Projects and Solutions->VC++ directories) are either from .config configuration files or from VCComponents.dat. That is, if users make any changes on the VC++ Directories setting, VCComponents.dat (AppData\Local\Microsoft\VisualStudio\9.0\VCComponents.dat, e.g. it is Vista and VS 2008) will be generated or updated. This file is per-user and per-machine.Whenever users launch Visual Studio, Visual Studio will read the settings from VCComponents.dat. If VCComponents.dat does not exist, then VS will read the setting information from VCProjectEnginee.dll.config (Program Files\Microsoft Visual Studio 9.0\VC\vcpackages, for each platform) configuration file.

(4) VS IDE provides both local setting and global setting. For example, Tools->Options->Projects and Solutions->VC++ Directories->Include, which is a global setting for headers which are used in all projects; Properties->Configuration Properties->C/C++->General->Additional Include Directories, which is a local setting for headers which only affects one project.

Comments