我是靠谱客的博主 野性发夹,最近开发中收集的这篇文章主要介绍不安装Visual Studio,只用Windows SDK搭建VC环境,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

首先你需要下载的是

Microsoft Windows SDK for Windows 7 and .NET Framework 4. 下载以后你得到的是一个网络安装文件,确保网络的连接,安装Windows SDK 7.1 (注意得到的Windows SDK 版本是7.1,这和我们安装Vsiual Studio得到的SDK 版本v7.0A是不一样的);

 

安装界面如下:



 
安装结束以后你应该得到如下的

1. 在c:Program FilesMicrosoft Visual Studio 10.0,你会看到不完全的Visual Studio的安装(主要是VC的库和头文件)

2.在C:Program FilesMicrosoft SDKsWindowsv7.1,你会看到Windows SDK的安装。

3. 在C:WindowsMicrosoft.NET,你会看到各个版本的Framework 的安装

4. 在HKLMSOFTWAREMicrosoftVisualStudioSxSVC7,你会看到如下的值

   “10.0”  “C:Program FilesMicrosoft Visual Studio 10.0VC”

   “FrameworkDir32" “C:WindowsMicrosoft.NETFramework”

   “FrameworkDir64" “C:WindowsMicrosoft.NETFramework64”

   "Framework32Ver” “v4.0.30319”

   "Framework64Ver” “v4.0.30319”

 

但是这样你还是不能运行vc++环境。首先你不能再PATH路径找到nmake,cl,而且,即使把cl加到了PATH路径中, 你也不能正确的运行编译,你需要一个脚本来初始化设置;

 

c:Program FilesMicrosoft Visual Studio 10.0中,有两个文件可以用来初始化环境,一个是Common7Toolsvsvars32.bat,另一个是VCvcvarsall.bat;

但是这两个文件需要更改,因为

1. 该文件查询注册HKLMSOFTWAREMicrosoftVisualStudioSxSVS7 表找寻VS的安装目录,但是HKLMSOFTWAREMicrosoftVisualStudioSxSVS7只有在完全安装Visual studio以后才存在。你需要的是通过HKLMSOFTWAREMicrosoftVisualStudioSxSVC7,通过去掉结尾的VC来间接的找到VS的安装目录。

:GetVSCommonToolsDirHelper32
@for /F "tokens=1,2*" %%i in ('reg query "%1SOFTWAREMicrosoftVisualStudioSxSVS7" /v "10.0"') DO (
@if "%%i"=="10.0" (
@SET "VS100COMNTOOLS=%%k"
)
)

 

2.文件查询HKLMSOFTWAREMicrosoft SDKsWindowsv7.0A来确定Windows SDK的安装目录,但是 该目录是安装Visual Studio时候才会安装的较低版本,安装了Windows SDK和Framework以后的Windows SDK版本更高,是v7.1;

:GetWindowsSdkDirHelper
@for /F "tokens=1,2*" %%i in ('reg query "%1SOFTWAREMicrosoftMicrosoft SDKsWindowsv7.0A" /v "InstallationFolder"') DO (
@if "%%i"=="InstallationFolder" (
@SET "WindowsSdkDir=%%k"
)
)

 

为了设置vc环境变量,我创建了my_vcvarsall.bat,内容如下:

 

@echo off
if "%1" == "" goto x86
if not "%2" == "" goto usage
if /i %1 == x86
goto x86
if /i %1 == amd64
goto amd64
if /i %1 == x64
goto amd64
if /i %1 == ia64
goto ia64
if /i %1 == x86_amd64 goto x86_amd64
if /i %1 == x86_ia64
goto x86_ia64
goto usage
:x86
if not exist "%~dp0binmy_vcvars32.bat" goto missing
call "%~dp0binmy_vcvars32.bat"
goto :eof
:amd64
if not exist "%~dp0binamd64vcvars64.bat" goto missing
call "%~dp0binamd64vcvars64.bat"
goto :eof
:ia64
if not exist "%~dp0binia64vcvars64.bat" goto missing
call "%~dp0binia64vcvars64.bat"
goto :eof
:x86_amd64
if not exist "%~dp0binx86_amd64vcvarsx86_amd64.bat" goto missing
call "%~dp0binx86_amd64vcvarsx86_amd64.bat"
goto :eof
:x86_ia64
if not exist "%~dp0binx86_ia64vcvarsx86_ia64.bat" goto missing
call "%~dp0binx86_ia64vcvarsx86_ia64.bat"
goto :eof
:usage
echo Error in script usage. The correct usage is:
echo
%0 [option]
echo where [option] is: x86 ^| ia64 ^| amd64 ^| x86_amd64 ^| x86_ia64
echo:
echo For example:
echo
%0 x86_ia64
goto :eof
:missing
echo The specified configuration type is missing.
The tools for the
echo configuration might not be installed.
goto :eof

 

该文件会调用%~dp0binmy_vcvars32.bat,,该文件的内容如下

@echo Setting environment for using Microsoft Visual Studio 2010 x86 tools.
@call :GetVSCommonToolsDir
@if "%VS100COMNTOOLS%"=="" goto error_no_VS100COMNTOOLSDIR
@call "%VS100COMNTOOLS%my_VCVarsQueryRegistry.bat" 32bit No64bit
@if "%VSINSTALLDIR%"=="" goto error_no_VSINSTALLDIR
@if "%FrameworkDir32%"=="" goto error_no_FrameworkDIR32
@if "%FrameworkVersion32%"=="" goto error_no_FrameworkVer32
@if "%Framework35Version%"=="" goto error_no_Framework35Version
@set FrameworkDir=%FrameworkDir32%
@set FrameworkVersion=%FrameworkVersion32%
@if not "%WindowsSdkDir%" == "" (
@set "PATH=%WindowsSdkDir%binNETFX 4.0 Tools;%WindowsSdkDir%bin;%PATH%"
@set "INCLUDE=%WindowsSdkDir%include;%INCLUDE%"
@set "LIB=%WindowsSdkDir%lib;%LIB%"
)
@rem
@rem Root of Visual Studio IDE installed files.
@rem
@set DevEnvDir=%VSINSTALLDIR%Common7IDE
@rem PATH
@rem ----
@if exist "%VSINSTALLDIR%Team ToolsPerformance Tools" (
@set "PATH=%VSINSTALLDIR%Team ToolsPerformance Tools;%PATH%"
)
@if exist "%ProgramFiles%HTML Help Workshop" set PATH=%ProgramFiles%HTML Help Workshop;%PATH%
@if exist "%ProgramFiles(x86)%HTML Help Workshop" set PATH=%ProgramFiles(x86)%HTML Help Workshop;%PATH%
@if exist "%VCINSTALLDIR%VCPackages" set PATH=%VCINSTALLDIR%VCPackages;%PATH%
@set PATH=%FrameworkDir%%Framework35Version%;%PATH%
@set PATH=%FrameworkDir%%FrameworkVersion%;%PATH%
@set PATH=%VSINSTALLDIR%Common7Tools;%PATH%
@if exist "%VCINSTALLDIR%BIN" set PATH=%VCINSTALLDIR%BIN;%PATH%
@set PATH=%DevEnvDir%;%PATH%
@if exist "%VSINSTALLDIR%VSTSDBDeploy" (
@set "PATH=%VSINSTALLDIR%VSTSDBDeploy;%PATH%"
)
@if not "%FSHARPINSTALLDIR%" == "" (
@set "PATH=%FSHARPINSTALLDIR%;%PATH%"
)
@rem INCLUDE
@rem -------
@if exist "%VCINSTALLDIR%ATLMFCINCLUDE" set INCLUDE=%VCINSTALLDIR%ATLMFCINCLUDE;%INCLUDE%
@if exist "%VCINSTALLDIR%INCLUDE" set INCLUDE=%VCINSTALLDIR%INCLUDE;%INCLUDE%
@rem LIB
@rem ---
@if exist "%VCINSTALLDIR%ATLMFCLIB" set LIB=%VCINSTALLDIR%ATLMFCLIB;%LIB%
@if exist "%VCINSTALLDIR%LIB" set LIB=%VCINSTALLDIR%LIB;%LIB%
@rem LIBPATH
@rem -------
@if exist "%VCINSTALLDIR%ATLMFCLIB" set LIBPATH=%VCINSTALLDIR%ATLMFCLIB;%LIBPATH%
@if exist "%VCINSTALLDIR%LIB" set LIBPATH=%VCINSTALLDIR%LIB;%LIBPATH%
@set LIBPATH=%FrameworkDir%%Framework35Version%;%LIBPATH%
@set LIBPATH=%FrameworkDir%%FrameworkVersion%;%LIBPATH%
@goto end
@REM -----------------------------------------------------------------------
:GetVSCommonToolsDir
@set VS100COMNTOOLS=
@call :GetVSCommonToolsDirHelper32 HKLM > nul 2>&1
@if errorlevel 1 call :GetVSCommonToolsDirHelper32 HKCU > nul 2>&1
@if errorlevel 1 call :GetVSCommonToolsDirHelper64
HKLM > nul 2>&1
@if errorlevel 1 call :GetVSCommonToolsDirHelper64
HKCU > nul 2>&1
@exit /B 0
:GetVSCommonToolsDirHelper32
@for /F "tokens=1,2*" %%i in ('reg query "%1SOFTWAREMicrosoftVisualStudioSxSVC7" /v "10.0"') DO (
@if "%%i"=="10.0" (
@SET "VS100COMNTOOLS=%%k"
)
)
echo SET "VS100COMNTOOLS=%VS100COMNTOOLS:VC=%"
@SET "VS100COMNTOOLS=%VS100COMNTOOLS:VC=%"
@if "%VS100COMNTOOLS%"=="" exit /B 1
@SET "VS100COMNTOOLS=%VS100COMNTOOLS%Common7Tools"
@exit /B 0
:GetVSCommonToolsDirHelper64
@for /F "tokens=1,2*" %%i in ('reg query "%1SOFTWAREWow6432NodeMicrosoftVisualStudioSxSVS7" /v "10.0"') DO (
@if "%%i"=="10.0" (
@SET "VS100COMNTOOLS=%%k"
)
)
@SET "VS100COMNTOOLS=%VS100COMNTOOLS:VC=%"
@if "%VS100COMNTOOLS%"=="" exit /B 1
@SET "VS100COMNTOOLS=%VS100COMNTOOLS%Common7Tools"
@exit /B 0
@REM -----------------------------------------------------------------------
:error_no_VS100COMNTOOLSDIR
@echo ERROR: Cannot determine the location of the VS Common Tools folder.
@goto end
:error_no_VSINSTALLDIR
@echo ERROR: Cannot determine the location of the VS installation.
@goto end
:error_no_FrameworkDIR32
@echo ERROR: Cannot determine the location of the .NET Framework 32bit installation.
@goto end
:error_no_FrameworkVer32
@echo ERROR: Cannot determine the version of the .NET Framework 32bit installation.
@goto end
:error_no_Framework35Version
@echo ERROR: Cannot determine the .NET Framework 3.5 version.
@goto end
:end

 

该文件会调用Common7Toolsmy_VCVarsQueryRegistry.bat文件, 该文件内容是

 

@call :GetWindowsSdkDir
@call :GetVSInstallDir
@call :GetVCInstallDir
@call :GetFSharpInstallDir
@if "%1"=="32bit" (
@call :GetFrameworkDir32
@call :GetFrameworkVer32
)
@if "%2"=="64bit" (
@call :GetFrameworkDir64
@call :GetFrameworkVer64
)
@SET Framework35Version=v3.5
@goto end
@REM -----------------------------------------------------------------------
:GetWindowsSdkDir
@set WindowsSdkDir=
@call :GetWindowsSdkDirHelper HKLM > nul 2>&1
@if errorlevel 1 call :GetWindowsSdkDirHelper HKCU > nul 2>&1
@if errorlevel 1 set WindowsSdkDir=%VCINSTALLDIR%PlatformSDK
@exit /B 0
:GetWindowsSdkDirHelper
@for /F "tokens=1,2*" %%i in ('reg query "%1SOFTWAREMicrosoftMicrosoft SDKsWindows
v7.1" /v "InstallationFolder"') DO (
@if "%%i"=="InstallationFolder" (
@SET "WindowsSdkDir=%%k"
)
)
@if "%WindowsSdkDir%"=="" exit /B 1
@exit /B 0
@REM -----------------------------------------------------------------------
:GetVSInstallDir
@set VSINSTALLDIR=
@call :GetVSInstallDirHelper32 HKLM > nul 2>&1
@if errorlevel 1 call :GetVSInstallDirHelper32 HKCU > nul 2>&1
@if errorlevel 1 call :GetVSInstallDirHelper64
HKLM > nul 2>&1
@if errorlevel 1 call :GetVSInstallDirHelper64
HKCU > nul 2>&1
@exit /B 0
:GetVSInstallDirHelper32
@for /F "tokens=1,2*" %%i in ('reg query "%1SOFTWAREMicrosoftVisualStudioSxSVC7" /v
"10.0"') DO (
@if "%%i"=="10.0" (
@SET "L_VCINSTALLDIR=%%k"
)
)
@SET "VSINSTALLDIR=%L_VCINSTALLDIR:VC=%"
@if "%VSINSTALLDIR%"=="" exit /B 1
@exit /B 0
:GetVSInstallDirHelper64
@for /F "tokens=1,2*" %%i in ('reg query "%1SOFTWAREWow6432NodeMicrosoftVisualStudio
SxSVC7" /v "10.0"') DO (
@if "%%i"=="10.0" (
SET "L_VS100VCInstallDirs=%%k"
SET "VSINSTALLDIR=%L_VS100VCInstallDirs:VC=%"
)
)
@if "%VSINSTALLDIR%"=="" exit /B 1
@exit /B 0
@REM -----------------------------------------------------------------------
:GetVCInstallDir
@set VCINSTALLDIR=
@call :GetVCInstallDirHelper32 HKLM > nul 2>&1
@if errorlevel 1 call :GetVCInstallDirHelper32 HKCU > nul 2>&1
@if errorlevel 1 call :GetVCInstallDirHelper64
HKLM > nul 2>&1
@if errorlevel 1 call :GetVCInstallDirHelper64
HKCU > nul 2>&1
@exit /B 0
:GetVCInstallDirHelper32
@for /F "tokens=1,2*" %%i in ('reg query "%1SOFTWAREMicrosoftVisualStudioSxSVC7" /v
"10.0"') DO (
@if "%%i"=="10.0" (
@SET "VCINSTALLDIR=%%k"
)
)
@if "%VCINSTALLDIR%"=="" exit /B 1
@exit /B 0
:GetVCInstallDirHelper64
@for /F "tokens=1,2*" %%i in ('reg query "%1SOFTWAREWow6432NodeMicrosoftVisualStudio
SxSVC7" /v "10.0"') DO (
@if "%%i"=="10.0" (
@SET "VCINSTALLDIR=%%k"
)
)
@if "%VCINSTALLDIR%"=="" exit /B 1
@exit /B 0
@REM -----------------------------------------------------------------------
:GetFSharpInstallDir
@set FSHARPINSTALLDIR=
@call :GetFSharpInstallDirHelper32 HKLM > nul 2>&1
@if errorlevel 1 call :GetFSharpInstallDirHelper32 HKCU > nul 2>&1
@if errorlevel 1 call :GetFSharpInstallDirHelper64
HKLM > nul 2>&1
@if errorlevel 1 call :GetFSharpInstallDirHelper64
HKCU > nul 2>&1
@exit /B 0
:GetFSharpInstallDirHelper32
@for /F "tokens=1,2*" %%i in ('reg query "%1SOFTWAREMicrosoftVisualStudio10.0SetupF#"
/v "ProductDir"') DO (
@if "%%i"=="ProductDir" (
@SET "FSHARPINSTALLDIR=%%k"
)
)
@if "%FSHARPINSTALLDIR%"=="" exit /B 1
@exit /B 0
:GetFSharpInstallDirHelper64
@for /F "tokens=1,2*" %%i in ('reg query "%1SOFTWAREWow6432NodeMicrosoftVisualStudio
10.0SetupF#" /v "ProductDir"') DO (
@if "%%i"=="ProductDir" (
@SET "FSHARPINSTALLDIR=%%k"
)
)
@if "%FSHARPINSTALLDIR%"=="" exit /B 1
@exit /B 0
@REM -----------------------------------------------------------------------
:GetFrameworkDir32
@set FrameworkDir32=
@call :GetFrameworkDir32Helper32 HKLM > nul 2>&1
@if errorlevel 1 call :GetFrameworkDir32Helper32 HKCU > nul 2>&1
@if errorlevel 1 call :GetFrameworkDir32Helper64
HKLM > nul 2>&1
@if errorlevel 1 call :GetFrameworkDir32Helper64
HKCU > nul 2>&1
@exit /B 0
:GetFrameworkDir32Helper32
@for /F "tokens=1,2*" %%i in ('reg query "%1SOFTWAREMicrosoftVisualStudioSxSVC7" /v
"FrameworkDir32"') DO (
@if "%%i"=="FrameworkDir32" (
@SET "FrameworkDIR32=%%k"
)
)
@if "%FrameworkDir32%"=="" exit /B 1
@exit /B 0
:GetFrameworkDir32Helper64
@for /F "tokens=1,2*" %%i in ('reg query "%1SOFTWAREWow6432NodeMicrosoftVisualStudio
SxSVC7" /v "FrameworkDir32"') DO (
@if "%%i"=="FrameworkDir32" (
@SET "FrameworkDIR32=%%k"
)
)
@if "%FrameworkDIR32%"=="" exit /B 1
@exit /B 0
@REM -----------------------------------------------------------------------
:GetFrameworkb64
@set FrameworkDir64=
@call :GetFrameworkDir64Helper32 HKLM > nul 2>&1
@if errorlevel 1 call :GetFrameworkDir64Helper32 HKCU > nul 2>&1
@if errorlevel 1 call :GetFrameworkDir64Helper64
HKLM > nul 2>&1
@if errorlevel 1 call :GetFrameworkDir64Helper64
HKCU > nul 2>&1
@exit /B 0
:GetFrameworkDir64Helper32
@for /F "tokens=1,2*" %%i in ('reg query "%1SOFTWAREMicrosoftVisualStudioSxSVC7" /v
"FrameworkDir64"') DO (
@if "%%i"=="FrameworkDir64" (
@SET "FrameworkDIR64=%%k"
)
)
@if "%FrameworkDIR64%"=="" exit /B 1
@exit /B 0
:GetFrameworkDir64Helper64
@for /F "tokens=1,2*" %%i in ('reg query "%1SOFTWAREWow6432NodeMicrosoftVisualStudio
SxSVC7" /v "FrameworkDir64"') DO (
@if "%%i"=="FrameworkDir64" (
@SET "FrameworkDIR64=%%k"
)
)
@if "%FrameworkDIR64%"=="" exit /B 1
@exit /B 0
@REM -----------------------------------------------------------------------
:GetFrameworkVer32
@set FrameworkVer32=
@call :GetFrameworkVer32Helper32 HKLM > nul 2>&1
@if errorlevel 1 call :GetFrameworkVer32Helper32 HKCU > nul 2>&1
@if errorlevel 1 call :GetFrameworkVer32Helper64
HKLM > nul 2>&1
@if errorlevel 1 call :GetFrameworkVer32Helper64
HKCU > nul 2>&1
@exit /B 0
:GetFrameworkVer32Helper32
@for /F "tokens=1,2*" %%i in ('reg query "%1SOFTWAREMicrosoftVisualStudioSxSVC7" /v
"FrameworkVer32"') DO (
@if "%%i"=="FrameworkVer32" (
@SET "FrameworkVersion32=%%k"
)
)
@if "%FrameworkVersion32%"=="" exit /B 1
@exit /B 0
:GetFrameworkVer32Helper64
@for /F "tokens=1,2*" %%i in ('reg query "%1SOFTWAREWow6432NodeMicrosoftVisualStudio
SxSVC7" /v "FrameworkVer32"') DO (
@if "%%i"=="FrameworkVer32" (
@SET "FrameworkVersion32=%%k"
)
)
@if "%FrameworkVersion32%"=="" exit /B 1
@exit /B 0
@REM -----------------------------------------------------------------------
:GetFrameworkVer64
@set FrameworkVer64=
@call :GetFrameworkVer64Helper32 HKLM > nul 2>&1
@if errorlevel 1 call :GetFrameworkVer64Helper32 HKCU > nul 2>&1
@if errorlevel 1 call :GetFrameworkVer64Helper64
HKLM > nul 2>&1
@if errorlevel 1 call :GetFrameworkVer64Helper64
HKCU > nul 2>&1
@exit /B 0
:GetFrameworkVer64Helper32
@for /F "tokens=1,2*" %%i in ('reg query "%1SOFTWAREMicrosoftVisualStudioSxSVC7" /v
"FrameworkVer64"') DO (
@if "%%i"=="FrameworkVer64" (
@SET "FrameworkVersion64=%%k"
)
)
@if "%FrameworkVersion64%"=="" exit /B 1
@exit /B 0
:GetFrameworkVer64Helper64
@for /F "tokens=1,2*" %%i in ('reg query "%1SOFTWAREWow6432NodeMicrosoftVisualStudio
SxSVC7" /v "FrameworkVer64"') DO (
@if "%%i"=="FrameworkVer64" (
@SET "FrameworkVersion64=%%k"
)
)
@if "%FrameworkVersion64%"=="" exit /B 1
@exit /B 0
@REM -----------------------------------------------------------------------
:end

 

至此,你可以起一个命令行,在代码里面敲入: 

C:Program FilesMicrosoft Visual Studio 10.0VCvcvarsall.bat

 

然后,就可以运行nmake,比如说来编译ruby的文件了。

 

如果你只是需要设置C#的环境,你需要修改添加Common7Toolsmy_vsvars32.bat,该文件的内容如下

@echo Setting environment for using Microsoft Visual Studio 2010 x86 tools.
@call :GetVSCommonToolsDir
@if "%VS100COMNTOOLS%"=="" goto error_no_VS100COMNTOOLSDIR
@call "%VS100COMNTOOLS%my_VCVarsQueryRegistry.bat" 32bit No64bit
@if "%VSINSTALLDIR%"=="" goto error_no_VSINSTALLDIR
@if "%FrameworkDir32%"=="" goto error_no_FrameworkDIR32
@if "%FrameworkVersion32%"=="" goto error_no_FrameworkVer32
@if "%Framework35Version%"=="" goto error_no_Framework35Version
@set FrameworkDir=%FrameworkDir32%
@set FrameworkVersion=%FrameworkVersion32%
@if not "%WindowsSdkDir%" == "" (
@set "PATH=%WindowsSdkDir%binNETFX 4.0 Tools;%WindowsSdkDir%bin;%PATH%"
@set "INCLUDE=%WindowsSdkDir%include;%INCLUDE%"
@set "LIB=%WindowsSdkDir%lib;%LIB%"
)
@rem
@rem Root of Visual Studio IDE installed files.
@rem
@set DevEnvDir=%VSINSTALLDIR%Common7IDE
@rem PATH
@rem ----
@if exist "%VSINSTALLDIR%Team ToolsPerformance Tools" (
@set "PATH=%VSINSTALLDIR%Team ToolsPerformance Tools;%PATH%"
)
@if exist "%ProgramFiles%HTML Help Workshop" set PATH=%ProgramFiles%HTML Help Workshop;
%PATH%
@if exist "%ProgramFiles(x86)%HTML Help Workshop" set PATH=%ProgramFiles(x86)%HTML Help
Workshop;%PATH%
@if exist "%VCINSTALLDIR%VCPackages" set PATH=%VCINSTALLDIR%VCPackages;%PATH%
@set PATH=%FrameworkDir%%Framework35Version%;%PATH%
@set PATH=%FrameworkDir%%FrameworkVersion%;%PATH%
@set PATH=%VSINSTALLDIR%Common7Tools;%PATH%
@if exist "%VCINSTALLDIR%BIN" set PATH=%VCINSTALLDIR%BIN;%PATH%
@set PATH=%DevEnvDir%;%PATH%
@if exist "%VSINSTALLDIR%VSTSDBDeploy" (
@set "PATH=%VSINSTALLDIR%VSTSDBDeploy;%PATH%"
)
@if not "%FSHARPINSTALLDIR%" == "" (
@set "PATH=%FSHARPINSTALLDIR%;%PATH%"
)
@rem INCLUDE
@rem -------
@if exist "%VCINSTALLDIR%ATLMFCINCLUDE" set INCLUDE=%VCINSTALLDIR%ATLMFCINCLUDE;%INCLUDE%
@if exist "%VCINSTALLDIR%INCLUDE" set INCLUDE=%VCINSTALLDIR%INCLUDE;%INCLUDE%
@rem LIB
@rem ---
@if exist "%VCINSTALLDIR%ATLMFCLIB" set LIB=%VCINSTALLDIR%ATLMFCLIB;%LIB%
@if exist "%VCINSTALLDIR%LIB" set LIB=%VCINSTALLDIR%LIB;%LIB%
@rem LIBPATH
@rem -------
@if exist "%VCINSTALLDIR%ATLMFCLIB" set LIBPATH=%VCINSTALLDIR%ATLMFCLIB;%LIBPATH%
@if exist "%VCINSTALLDIR%LIB" set LIBPATH=%VCINSTALLDIR%LIB;%LIBPATH%
@set LIBPATH=%FrameworkDir%%Framework35Version%;%LIBPATH%
@set LIBPATH=%FrameworkDir%%FrameworkVersion%;%LIBPATH%
@goto end
@REM -----------------------------------------------------------------------
:GetVSCommonToolsDir
@set VS100COMNTOOLS=
@call :GetVSCommonToolsDirHelper32 HKLM > nul 2>&1
@rem call :GetVSCommonToolsDirHelper32 HKLM
@if errorlevel 1 call :GetVSCommonToolsDirHelper32 HKCU > nul 2>&1
@if errorlevel 1 call :GetVSCommonToolsDirHelper64
HKLM > nul 2>&1
@if errorlevel 1 call :GetVSCommonToolsDirHelper64
HKCU > nul 2>&1
@exit /B 0
:GetVSCommonToolsDirHelper32
@for /F "tokens=1,2*" %%i in ('reg query "%1SOFTWAREMicrosoftVisualStudioSxSVC7" /v
"10.0"') DO (
@if "%%i"=="10.0" (
@SET "L_VS100VCInstallDirs=%%k"
)
)
@echo SET "VS100COMNTOOLS=%L_VS100VCInstallDirs:VC=%"
@SET "VS100COMNTOOLS=%L_VS100VCInstallDirs:VC=%"
@if "%VS100COMNTOOLS%"=="" exit /B 1
@SET "VS100COMNTOOLS=%VS100COMNTOOLS%Common7Tools"
@exit /B 0
:GetVSCommonToolsDirHelper64
@for /F "tokens=1,2*" %%i in ('reg query "%1SOFTWAREWow6432NodeMicrosoftVisualStudio
SxSVC7" /v "10.0"') DO (
@if "%%i"=="10.0" (
SET "L_VS100VCInstallDirs=%%k"
SET "VS100COMNTOOLS=%L_VS100VCInstalldirs:VC=%"
)
)
@if "%VS100COMNTOOLS%"=="" exit /B 1
@SET "VS100COMNTOOLS=%VS100COMNTOOLS%Common7Tools"
@exit /B 0
@REM -----------------------------------------------------------------------
:error_no_VS100COMNTOOLSDIR
@echo ERROR: Cannot determine the location of the VS Common Tools folder.
@goto end
:error_no_VSINSTALLDIR
@echo ERROR: Cannot determine the location of the VS installation.
@goto end
:error_no_FrameworkDIR32
@echo ERROR: Cannot determine the location of the .NET Framework 32bit installation.
@goto end
:error_no_FrameworkVer32
@echo ERROR: Cannot determine the version of the .NET Framework 32bit installation.
@goto end
:error_no_Framework35Version
@echo ERROR: Cannot determine the .NET Framework 3.5 version.
@goto end
:end

 

如代码所示,你Common7Toolsmy_vsvars32.bat 会调用Common7Toolsmy_VCVarsQueryRegistry.bat 的文件;my_VCVarsQueryRegistry.bat的文件内容在上面已经已经介绍了。

 

至此,所有的配置都已经结束,本文中的配置只是在win32 x85环境下测试过了,没有测试过amd64,但是思路是一样的,你可以按照类似的方法调试通过64的配置;

 

 

References:

Microsoft Windows SDK for Windows 7 and .NET Framework 4

最后

以上就是野性发夹为你收集整理的不安装Visual Studio,只用Windows SDK搭建VC环境的全部内容,希望文章能够帮你解决不安装Visual Studio,只用Windows SDK搭建VC环境所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(45)

评论列表共有 0 条评论

立即
投稿
返回
顶部