如何让 Visual Studio 2012 调用本机 64 位 Visual C++ 编译器而不是 32 位 x64 交叉编译器? [英] How to make Visual Studio 2012 call the native 64-bit Visual C++ compiler instead of the 32-bit x64 cross-compiler?

查看:42
本文介绍了如何让 Visual Studio 2012 调用本机 64 位 Visual C++ 编译器而不是 32 位 x64 交叉编译器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Visual Studio 2012 似乎总是调用位于 %ProgramFiles(x86)%\Microsoft Visual Studio 11.0\VC\bin\x86_amd64cl.exe 的 32 位版本code>) 而不是位于 %ProgramFiles(x86)%\Microsoft Visual Studio 11.0\VC\bin\amd64 的 64 位.

Visual Studio 2012 seems to always call the 32-bit version of cl.exe located at %ProgramFiles(x86)%\Microsoft Visual Studio 11.0\VC\bin\x86_amd64) instead of the 64-bit one located at %ProgramFiles(x86)%\Microsoft Visual Studio 11.0\VC\bin\amd64.

我尝试将 $(VCInstallDir)bin\amd64 放在 Microsoft.Cpp 的 VC++ 目录 部分中可执行目录"列表的开头.x64.user 属性表,但这根本不起作用 - 当我重建时出现此错误:

I tried prepending $(VCInstallDir)bin\amd64 to the beginning of the "Executable Directories" list in the VC++ Directories section of the Microsoft.Cpp.x64.user property sheet, but that doesn't work at all -- when I rebuild I get this error:

TRACKER : error TRK0002: Failed to execute command: "
"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\amd64\CL.exe"
@C:\Users\<my_profile>\AppData\Local\Temp\tmpf3d817cafe064ad28e7dd62b2cb591c3.rsp
". The operation identifier is not valid.

如何让 Visual Studio 2012 使用本机 64 位 C++ 编译器?

How can I make Visual Studio 2012 use the native 64-bit C++ compiler?

推荐答案

这个答案有点晚了,但令人沮丧的是,微软的在线文档仍然没有直接可用的好的资源.事实证明这很容易,即使不是很方便.

This answer is a bit late to the party, but frustratingly there's still no good resource directly available from Microsoft's online documentation. It turns out to be easy, even if not totally convenient.

在命令提示符下,键入(根据需要更改 VS 的版本):

At the command prompt, type (changing the version of VS to your needs):

> set _IsNativeEnvironment=true
> "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe" YourProject.sln

这个的线索在文件中

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.Cpp.targets

它说的地方

<SetEnv Condition="'$(_IsNativeEnvironment)' == 'true'"
        Name ="PATH"
        Value ="$(NativeExecutablePath)"
        Prefix ="false">
  <Output TaskParameter="OutputEnvironmentVariable" PropertyName="Path"/>
</SetEnv>

我的项目是由 CMake 生成的,所以我通常在命令提示符下输入几行,然后我才能打开 VS.我总是在第一次设置 MSVC 环境后启动我的 CMake 生成器,所以老实说我不知道​​它是否需要,但你也可以选择做(在其他一切之前):

My project is generated by CMake, so I am usually at the command prompt for a few lines before I can open VS anyway. I have always started my CMake generators after first setting up the MSVC environment, so I honestly don't know if it's required or not, but you can optionally also do (before everything else):

> call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" amd64

和/或

> call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\amd64\vcvars64.bat"

这是MSDN 上的原始帖子 在那里我终于找到了答案.

Here's the link to the original post on MSDN where I finally found the answer.

这篇关于如何让 Visual Studio 2012 调用本机 64 位 Visual C++ 编译器而不是 32 位 x64 交叉编译器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆