views:

404

answers:

3

Currently Visual Studio just starts cl.exe for C++ source compilation. cl.exe needs to be in one of folders listed on the %PATH% environment variable.

Since there're separate versions of cl.exe for 32-bit and 64-bit compilation in order to compile a 32-bit project after compiling a 64-bit project it is necessary to restart Visual Studio.

The typical solution is to have two .cmd files each settings %PATH% appropriately and then starting Visual Studio. Is there a solution that doesn't require restarting Visual Studio?

+6  A: 

You do not have to restart. Just setup two 'Solution Platforms' (Win32 and x64 for example) in your solution and projects and you are ready to go, as Visual Studio will automatically find the correct tools.

stijn
+1 - I didn't think about two platforms, your solution is simpler than the one I thought of.
James Black
Nope, it didn't work. Either I set up %PATH% and it works for one (correct) platfowm or I don't set up %PATH% and it can't find cl.exe.
sharptooth
Then you have done something very peculiar to your build environment. That is not default behaviour at all.
DrPizza
indeed; maybe you messed with the PATH too much so that the environment is not ok anymore. To check if basic things still work, try if your project builds with msbuild, if you're a bit familiar with it. Also note that the correct way to set the path for VS tools is by running VSINSTALLDIR/VC/vcvarsall.bat with the platform as argument.
stijn
A: 

There is always the Build->Batch Build command, in which you can select the configurations to build.

xtofl
A: 

Currently Visual Studio just starts cl.exe for C++ source compilation. cl.exe needs to be in one of folders listed on the %PATH% environment variable.

That isn't true. VS does not depend on the path to locate cl.exe (cl.exe is not in my path, but VC++ can compiler perfectly well regardless). I think it uses either the registry, or else it uses the configuration stored in Tools/Options/Projects and Solutions/VC++ Directories.

Since there're separate versions of cl.exe for 32-bit and 64-bit compilation in order to compile a 32-bit project after compiling a 64-bit project it is necessary to restart Visual Studio.

No, just create different targets for the project.

DrPizza