vcvarsall - 使用64位编译器,然后切换回32位进行单独构建

时间:2023-01-03 12:27:00

I'm using vcvarsall to switch to x64 compile tools for VS2010, as I run into memory issues with a certain build. However I'd like to also switch BACK to x86 tools for regular builds.

我正在使用vcvarsall切换到VS2010的x64编译工具,因为我遇到了某个版本的内存问题。但是,我还想将BACK切换到x86工具以进行常规构建。

Currently I have a batch file that looks like this:

目前我有一个如下所示的批处理文件:

CALL "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x64
set _IsNativeEnvironment=true

"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv" "C:\Development\projectx.sln" /build "Debug|x64"

CALL "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86
set _IsNativeEnvironment=true

"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv" "C:\Development\projectx.sln" /build "Debug|x86"

This works for the first build, but the second will still launch 64bit compiler/linker - which gives errors occasionally (why I need to use 32 for it). In testing I found that it will work only if I open a new command line after running the x86 vcvarsall.bat - how can I mimic this in a batch file?

这适用于第一次构建,但第二次仍将启动64位编译器/链接器 - 偶尔会出现错误(为什么我需要使用32)。在测试中,我发现只有在运行x86 vcvarsall.bat后打开一个新的命令行才能工作 - 我怎样才能在批处理文件中模仿它?

1 个解决方案

#1


1  

Use setlocal and endlocal

使用setlocal和endlocal

setlocal
CALL "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x64
set _IsNativeEnvironment=true

"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv" "C:\Development\projectx.sln" /build "Debug|x64"
endlocal

setlocal
CALL "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86
set _IsNativeEnvironment=true

"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv" "C:\Development\projectx.sln" /build "Debug|x86"
endlocal

#1


1  

Use setlocal and endlocal

使用setlocal和endlocal

setlocal
CALL "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x64
set _IsNativeEnvironment=true

"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv" "C:\Development\projectx.sln" /build "Debug|x64"
endlocal

setlocal
CALL "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86
set _IsNativeEnvironment=true

"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv" "C:\Development\projectx.sln" /build "Debug|x86"
endlocal