用WDK命令行CMD編譯一個(gè)驅(qū)動(dòng)程序時(shí),關(guān)于環(huán)境變量的記錄
當(dāng)使用WDK(我這里版本W(wǎng)DK 7600.16385.1)命令行編譯一個(gè)驅(qū)動(dòng)程序時(shí),進(jìn)入到當(dāng)前驅(qū)動(dòng)所在的文件夾目錄下,一般都有一個(gè)Sources文件,內(nèi)容一般是:
TARGETNAME=UsbKbd TARGETTYPE=DRIVER DRIVERTYPE=WDM TARGETPATH=OBJ #TARGETLIBS=C:98DDKLIBI386FREEUsbd.Lib TARGETLIBS=$(DDK_LIB_PATH)Usbd.Lib INCLUDES=$(BASEDIR)inc; SOURCES= Init.cpp? Dispatch.cpp? Pnp.cpp? DeviceIo.cpp? Usb.cpp? DebugPrint.c? # UsbKbd.rc NTTARGETFILES=PostBuildSteps
例如上面的Sources例子里(是編譯UsbKbd驅(qū)動(dòng)),“#”是注釋符,“DDK_LIB_PATH”等環(huán)境變量定義在什么地方呢?
開啟一個(gè)WDK命令行編譯環(huán)境,執(zhí)行下面操作:
C:WinDDK7600.16385.1>set?>c:1.txt
上面操作的意思是,將當(dāng)前命令行cmd下所有的環(huán)境變量輸出到c:1.txt內(nèi),打開該文件,如下:
386=1 ALLUSERSPROFILE=C:ProgramData APPDATA=C:UsersAdministratorAppDataRoaming asl.log=Destination=file ATL_INC_PATH=C:WinDDK7600.16385.1inc ATL_INC_ROOT=C:WinDDK7600.16385.1inc ATL_LIB_PATH=C:WinDDK7600.16385.1libatl* BASEDIR=C:WinDDK7600.16385.1 BUILD_ALLOW_COMPILER_WARNINGS=1 BUILD_ALT_DIR=chk_wxp_x86 BUILD_DEFAULT=-ei?-nmake?-i?-nosqm BUILD_DEFAULT_TARGETS=-386 BUILD_MAKE_PROGRAM=nmake.exe BUILD_MULTIPROCESSOR=1 BUILD_OACR=1 COFFBASE_TXT_FILE=C:WinDDK7600.16385.1bincoffbase.txt CommonProgramFiles=C:Program?FilesCommon?Files CommonProgramFiles(x86)=C:Program?Files?(x86)Common?Files CommonProgramW6432=C:Program?FilesCommon?Files COMPUTERNAME=XT1-20140726YGA ComSpec=C:Windowssystem32cmd.exe CPU=AMD64 CRT_INC_PATH=C:WinDDK7600.16385.1inccrt CRT_LIB_PATH=C:WinDDK7600.16385.1libcrt* DDKBUILDENV=chk DDK_INC_PATH=C:WinDDK7600.16385.1incddk DDK_LIB_DEST=C:WinDDK7600.16385.1libwxp DDK_LIB_PATH=C:WinDDK7600.16385.1libwxp* DDK_TARGET_OS=WinXP DEPRECATE_DDK_FUNCTIONS=1 DEVMGR_SHOW_DETAILS=1 DRIVER_INC_PATH=C:WinDDK7600.16385.1incddk FP_NO_HOST_CHECK=NO HALKIT_INC_PATH=C:WinDDK7600.16385.1incddk HALKIT_LIB_PATH=C:WinDDK7600.16385.1libwxp* HOMEDRIVE=C: HOMEPATH=UsersAdministrator IFSKIT_INC_PATH=C:WinDDK7600.16385.1incddk IFSKIT_LIB_DEST=C:WinDDK7600.16385.1libwxp IFSKIT_LIB_PATH=C:WinDDK7600.16385.1libwxp* Include=C:WinDDK7600.16385.1incapi KMDF_INC_PATH=C:WinDDK7600.16385.1incwdfkmdf KMDF_LIB_PATH=C:WinDDK7600.16385.1libwdfkmdf* LANGUAGE_NEUTRAL=0 Lib=C:WinDDK7600.16385.1lib LINK_LIB_IGNORE=4198 LOCALAPPDATA=C:UsersAdministratorAppDataLocal LOGONSERVER=\XT1-20140726YGA MFC_INC_PATH=C:WinDDK7600.16385.1incmfc42 MFC_LIB_PATH=C:WinDDK7600.16385.1libmfc* MSC_OPTIMIZATION=/Od?/Oi? NEW_CRTS=1 NO_BINPLACE=TRUE NO_BROWSER_FILE=TRUE NTDBGFILES=1 NTDEBUG=ntsd NTDEBUGTYPE=both NTMAKEENV=C:WinDDK7600.16385.1bin NUMBER_OF_PROCESSORS=4 OAK_INC_PATH=C:WinDDK7600.16385.1incapi OS=Windows_NT Path=C:WinDDK7600.16385.1binamd64;C:WinDDK7600.16385.1toolssdvbin;C:WinDDK7600.16385.1binx86oacr;C:WinDDK7600.16385.1toolspfdbinbinx86;C:WinDDK7600.16385.1toolstracingi386;C:WinDDK7600.16385.1binx86;C:WinDDK7600.16385.1binx86x86;C:WinDDK7600.16385.1binSelfSign;C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:Program?Files?(x86)Windows?Kits8.0Windows?Performance?Toolkit;C:Program?FilesMicrosoft?SQL?Server110ToolsBinn PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC PREFAST_VALID_IMPLIES_NOTNULL=1 PROCESSOR_ARCHITECTURE=AMD64 PROCESSOR_IDENTIFIER=Intel64?Family?6?Model?58?Stepping?9,?GenuineIntel PROCESSOR_LEVEL=6 PROCESSOR_REVISION=3a09 ProgramData=C:ProgramData ProgramFiles=C:Program?Files ProgramFiles(x86)=C:Program?Files?(x86) ProgramW6432=C:Program?Files PROJECT_ROOT=C:WinDDK7600.16385.1src PROMPT=$P$G PSModulePath=C:Windowssystem32WindowsPowerShellv1.0Modules PUBLIC=C:UsersPublic PUBLIC_ROOT=C:WinDDK7600.16385.1 PUBLISH_CMD=@echo?Publish?not?available... RAZZLETOOLPATH=C:WinDDK7600.16385.1Bin RCNOFONTMAP=1 SDK_INC_PATH=C:WinDDK7600.16385.1incapi SDK_LIB_DEST=C:WinDDK7600.16385.1libwxp SDK_LIB_PATH=C:WinDDK7600.16385.1libwxp* SDV=C:WinDDK7600.16385.1toolssdv separate_object_root=FALSE SESSIONNAME=Console SUBSTITUTE_386_CC=C:WinDDK7600.16385.1Binx86oacroacrcl SUBSTITUTE_AMD64_CC=C:WinDDK7600.16385.1Binx86oacroacrcl SUBSTITUTE_CS_COMPILER_NAME=C:WinDDK7600.16385.1BINx86oacroacrcsc?/nologo SUBSTITUTE_LINK=C:WinDDK7600.16385.1Binx86oacroacrlink SystemDrive=C: SystemRoot=C:Windows TEMP=C:UsersADMINI~1AppDataLocalTemp TMP=C:UsersADMINI~1AppDataLocalTemp UMDF_INC_PATH=C:WinDDK7600.16385.1incwdfumdf USERDOMAIN=XT1-20140726YGA USERNAME=WinDDK USERPROFILE=C:UsersAdministrator USE_OBJECT_ROOT=1 VBOX_MSI_INSTALL_PATH=C:Program?FilesOracleVirtualBox VS110COMNTOOLS=C:Program?Files?(x86)Microsoft?Visual?Studio?11.0Common7Tools WDM_INC_PATH=C:WinDDK7600.16385.1incddk windir=C:Windows windows_tracing_flags=3 windows_tracing_logfile=C:BVTBinTestsinstallpackagecsilogfile.log WPP_CONFIG_PATH=C:WinDDK7600.16385.1binwppconfig _BUILDARCH=x86 _BuildType=chk _DFX_INSTALL_UNSIGNED_DRIVER=1 _IA32bit=true _NTDRIVE=C: _NTROOT=WinDDK7600.16385.1 _NT_TARGET_VERSION=0x501 _OACR_ERROR_LEVEL=0 _RunOacr=TRUE
在這里,就能找到“DDK_LIB_PATH”等環(huán)境變量定義值了。(如上我開啟的是WinXP的Check版本的編譯環(huán)境)
舉一反三:
① ?啟動(dòng)一個(gè)默認(rèn)的CMD命令行環(huán)境,執(zhí)行“set >c:1.txt”后,再開啟VS2012的命令行提示編譯環(huán)境,執(zhí)行“set >c:2.txt”,用文件比較工具比較兩個(gè)文件的不同。這兩個(gè)文件的不同,就是VS2012命令行編譯環(huán)境做的特殊設(shè)置。
② 用同樣的方式,可以查看WinCE5.0、Tornado2.2命令行編譯設(shè)置的不同;
② 用同樣的方式,查看Visual Studio之間做的設(shè)置環(huán)境變量區(qū)別:VC++6.0的設(shè)置環(huán)境變量位置一般在“C:Program Files (x86)Microsoft Visual StudioVC98Bin”下,為“VCVARS32.BAT”;VS2005,VS2008,VS2012分別在菜單下有命令行編譯提示工具設(shè)置;