gpt4 book ai didi

windows - 我如何从命令提示符下使用 Visual Studio 2012 为 Windows XP 编译

转载 作者:可可西里 更新时间:2023-11-01 11:56:10 26 4
gpt4 key购买 nike

我正在运行带有外部 c 库的 tcl/tk (8.5) 以连接到 d2xx USB 库。我正在运行 Windows 8 并尝试使用 VS 2012 Native Tools 命令提示符编译库。当我启动命令提示符时,我的 PWD 是:

\Program Files (x86)\Microsoft Visual Studio 11.0\VC

c 库 (tclftd2xx.c) 带有用于虚拟工作室的 nmake 文件,可以正确设置环境以链接到所需的 tcl 库和 d2xx header 。

在 VS 命令窗口中,我 CD 到包含 makefile.vc 的目录并键入:

nmake .....

我得到了我的 tclftd2xx.dll。

tclftd2xx.dll 调用 msvcr110.dll。当这两者都正确放置在/Tcl/lib 中时,它们在我的 Windows 8 系统、Vista 和 Windows 7 上运行良好。

但是,当安装在 Windows XP 上时,windows 无法加载 tclftd2xx.dll。

我做了一些搜索,发现我必须为 v110_xp 工具集配置 VS2012。链接 ( http://blogs.msdn.com/b/vcblog/archive/2012/10/08/10357555.aspx ) 有这条注释:

Visual Studio 2012 solutions and projects which have been switched to the v110_xp toolset can be built from the command line using MSBuild or DEVENV without additional steps.

However, if you wish to use CL and Link directly, additional steps are needed. Note that the steps below may be automated by creating a batch script.

我在这里做的:

REM set include and path variables
set INCLUDE=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Include;%INCLUDE%
set PATH=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Bin;%PATH%

REM When targeting X86, set the lib path as follows:
set LIB=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Lib;%LIB%

REM set the compiler options
set CL=/D_USING_V110_SDK71_;%CL%

REM When targeting x64, set the lib path as follows:
REM set LIB=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Lib\x64;%LIB%

REM Specify the correct subsystem and subsystem version for the linker based on the type of
REM application you are building. Applications targeting the x86 version of Windows XP must specify
REM subsystem version 5.01, and applications targeting x64 must specify version 5.02.

REM For x86 console applications:
set LINK=/SUBSYSTEM:CONSOLE,5.01 %LINK%

REM For x64 console applications:
REM set LINK=/SUBSYSTEM:CONSOLE,5.02 %LINK%

要从 VS 命令行构建 xp 版本,我1)运行.bat文件2) nmake .....

我得到一个与 Windows 8 目标 dll 大小完全相同的 .dll。

所以我有两个问题:

  1. 除了执行 .bat 文件 之外,我是否还必须运行其他一些神奇的配置脚本或环境变量来启用 v110_xp 工具集,或者执行 .bat 文件是否会进行完整配置?
  2. 除了尝试在 XP 系统上加载它之外,是否有其他方法可以确认 .dll 确实针对 XP 系统?

最佳答案

我想出了以下批处理脚本来设置变量。看来,我必须将其包含在我的项目中,以便人们使用 visual studio 2012 构建我的代码。

@echo off
goto :start

:check_dir
if not exist "%~1" (
echo Directory "%~1" does not exist.
echo Things may not work as expected.
)
goto :eof

:start
setlocal
if "%PROCESSOR_ARCHITECTURE%" == "x86" (
set "ProgramFiles(x86)=%ProgramFiles%"
)

set "BINDIR=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Bin"
set "INCDIR=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Include"
set "LIBDIR=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Lib"
set "SUBSYS=CONSOLE,5.01"

REM for x64 instead of x86:
REM set "LIBDIR=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Lib\x64"
REM set "SUBSYS=CONSOLE,5.02"

call :check_dir "%%BINDIR%%"
call :check_dir "%%INCDIR%%"
call :check_dir "%%LIBDIR%%"

endlocal & (
set "CL=/D_USING_V110_SDK71_;%CL%"
set "LINK=/SUBSYSTEM:%SUBSYS% %LINK%"
set "LIB=%LIBDIR%;%LIB%"
set "PATH=%BINDIR%;%PATH%"
set "INCLUDE=%INCDIR%;%INCLUDE%"
)

关于windows - 我如何从命令提示符下使用 Visual Studio 2012 为 Windows XP 编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16075171/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com