如何使用 Visual C++ 2010 Express 编译 64 位应用程序?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1865069/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to compile a 64-bit application using Visual C++ 2010 Express?
提问by Nathan Osman
Is there a simple way to compile a 64 bit app with the 32-bit edition of Visual C++ 2010 Express? What configurations, if any, are necessary?
是否有一种简单的方法可以使用 32 位版本的 Visual C++ 2010 Express 编译 64 位应用程序?需要哪些配置(如果有)?
回答by Matt
Here are step by step instructions:
以下是分步说明:
- Download and install the Windows Software Development Kit version 7.1. Visual C++ 2010 Express does not include a 64 bit compiler, but the SDK does. A link to the SDK: http://msdn.microsoft.com/en-us/windowsserver/bb980924.aspx
- Change your project configuration. Go to Properties of your project. On the top of the dialog box there will be a "Configuration" drop-down menu. Make sure that selects "All Configurations." There will also be a "Platform" drop-down that will read "Win32." Finally on the right there is a "Configuration Manager" button - press it. In the dialog that comes up, find your project, hit the Platform drop-down, select New, then select x64. Now change the "Active solution platform" drop-down menu to "x64." When you return to the Properties dialog box, the "Platform" drop-down should now read "x64."
- Finally, change your toolset. In the Properties menu of your project, under Configuration Properties | General, change Platform Toolset from "v100" to "Windows7.1SDK".
- 下载并安装 Windows 软件开发工具包 7.1 版。Visual C++ 2010 Express 不包含 64 位编译器,但 SDK 包含。SDK 的链接:http: //msdn.microsoft.com/en-us/windowsserver/bb980924.aspx
- 更改您的项目配置。转到项目的属性。在对话框的顶部会有一个“配置”下拉菜单。确保选择“所有配置”。还会有一个“平台”下拉菜单,上面写着“Win32”。最后在右侧有一个“配置管理器”按钮 - 按下它。在出现的对话框中,找到您的项目,点击平台下拉菜单,选择新建,然后选择 x64。现在将“活动解决方案平台”下拉菜单更改为“x64”。当您返回到“属性”对话框时,“平台”下拉列表现在应显示为“x64”。
- 最后,更改您的工具集。在项目的“属性”菜单中,在“配置属性”下 | 一般,将平台工具集从“v100”更改为“Windows7.1SDK”。
These steps have worked for me, anyway. Some more details on step 2 can be found in a reference from Microsoft that a previous poster mentioned: http://msdn.microsoft.com/en-us/library/9yb4317s.aspx.
无论如何,这些步骤对我有用。关于第 2 步的更多详细信息可以在 Microsoft 的参考资料中找到,之前的海报提到过:http: //msdn.microsoft.com/en-us/library/9yb4317s.aspx。
回答by YOU
64-bit tools are not available on Visual C++ Express by default. To enable 64-bit tools on Visual C++ Express, install the Windows Software Development Kit (SDK) in addition to Visual C++ Express. Otherwise, an error occurs when you attempt to configure a project to target a 64-bit platform using Visual C++ Express.
默认情况下,64 位工具在 Visual C++ Express 上不可用。要在 Visual C++ Express 上启用 64 位工具,除安装 Visual C++ Express 外,还需要安装 Windows 软件开发工具包 (SDK)。否则,当您尝试使用 Visual C++ Express 将项目配置为面向 64 位平台时会发生错误。
How to: Configure Visual C++ Projects to Target 64-Bit Platforms
如何:将 Visual C++ 项目配置为面向 64 位平台
回答by Jamie Fristrom
And make sure you download the Windows7.1SDK, not just the Windows 7 one. That caused me a lot of head pounding.
并确保您下载 Windows7 .1SDK,而不仅仅是 Windows 7 SDK。这让我很头疼。
回答by Matt
I found an important step to add to this - after you've installed the SDK, go to your project properties and change Configuration Properties->General->Platform Toolset from v100 or whatever it is to Windows7.1SDK. This changes $(WindowsSdkDir) to the proper place and seemed to solve some other difficulties I was encountering as well.
我发现了一个重要的步骤 - 在你安装了 SDK 之后,转到你的项目属性并将 Configuration Properties->General->Platform Toolset 从 v100 或任何它更改为 Windows7.1SDK。这将 $(WindowsSdkDir) 更改为适当的位置,似乎也解决了我遇到的其他一些困难。
回答by Matt
Note that Visual C++ compilers are removed when you upgrade Visual Studio 2010 Professional or Visual Studio 2010 Express to Visual Studio 2010 SP1 if Windows SDK v7.1 is installed.
请注意,如果安装了 Windows SDK v7.1,则在将 Visual Studio 2010 Professional 或 Visual Studio 2010 Express 升级到 Visual Studio 2010 SP1 时会删除 Visual C++ 编译器。
For instructions on resolving this, see KB2519277on the Microsoft Support site.
有关解决此问题的说明,请参阅Microsoft 支持站点上的KB2519277。
回答by duduong
Download the Windows SDK and then go to View->Properties->Configuration Manager->Active Solution Platform->New->x64.
下载 Windows SDK,然后转到查看->属性->配置管理器->活动解决方案平台->新建->x64。
回答by perilbrain
Programming in a 64-bit environment is quite different than 32-bit environment. Code generated has totally different assembly constitution in 32 & 64-bit code, even the protocols of communicating with functions change. So you can't generate 64-bit code using 32-bit compiler.
在 64 位环境中编程与在 32 位环境中完全不同。生成的代码在 32 位和 64 位代码中具有完全不同的汇编构成,甚至与函数通信的协议也发生了变化。因此,您无法使用 32 位编译器生成 64 位代码。
You might want to see an article on Microsoft's web siteabout targeting a 64-bit target but using a 32-bit development machine.
您可能希望在 Microsoft 网站上查看一篇关于定位 64 位目标但使用 32 位开发机器的文章。
回答by Hadrien Huvelle
As what Jakob said: windows sdk 7.1 cannot be installed if MS VC++ x64 and x86 runtimes and redisrtibutables of version 10.0.40219 are present. after removing them win sdk install is okay, VS C++ SP1 can be installed fine again.
正如 Jakob 所说:如果存在 MS VC++ x64 和 x86 运行时以及版本 10.0.40219 的可再发行组件,则无法安装 windows sdk 7.1。删除它们后,win sdk install 就可以了,VS C++ SP1 可以再次安装正常。
Kind regards
亲切的问候