How to make Visual Studio 2012 call the native 64-bit Visual C++ compiler instead of the 32-bit x64 cross-compiler?

后端 未结 2 1761
别跟我提以往
别跟我提以往 2021-02-09 05:36

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)

2条回答
  •  臣服心动
    2021-02-09 06:04

    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.

    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
    

    The clue for this is in the file

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

    where it says

    
      
    
    

    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
    

    and /or

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

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

提交回复
热议问题