windows 如何编译 64 位版本的 dll?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1159161/
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 bits version of my dll?
提问by vectorizor
Probably a dumb question: I have a WinXP 32bits desktop that I use to compile a (32 bits) dll with Visual Studio 2005/Intel COmpiler 10.1. I would like to generate a 64 bits version of my dll. How to do that? Answers related to Visual Studio are interesting, but those addressing the Intel compiler side of things get extra brownie points.
可能是个愚蠢的问题:我有一个 WinXP 32 位桌面,我用它来用 Visual Studio 2005/Intel COmpiler 10.1 编译(32 位)dll。我想生成一个 64 位版本的 dll。怎么做?与 Visual Studio 相关的答案很有趣,但那些解决英特尔编译器方面的问题会获得额外的积分。
Thanks in advance.
提前致谢。
ALex
亚历克斯
回答by joe
This little guide I made is to make the VC++ 2005 Express compile 64bit using the latest PSDK(altough I'm not sure how good it works)
我制作的这个小指南是使用最新的 PSDK使VC++ 2005 Express 编译 64 位(虽然我不确定它的效果如何)
I'll assume you already have VC++ 2005 Express and the PSDK installed, and activated the Win32 application building in VC++ and running 64bit Windows (well it maybe works in 32bit windows too but the exe will not run in that enviroment)
我假设您已经安装了 VC++ 2005 Express 和 PSDK,并激活了在 VC++ 中构建的 Win32 应用程序并运行 64 位 Windows(它可能也适用于 32 位 Windows,但 exe 不会在该环境中运行)
1) Start -> All Programs -> Microsoft Platform SDK for Windows Server 2003 SP1 -> Windows XP 64-bit Build Environment -> Set Windows XP x64 Build Environment (Debug/Retail) <- doesn't mather which one at this moment
1) 开始 -> 所有程序 -> Microsoft Platform SDK for Windows Server 2003 SP1 -> Windows XP 64-bit Build Environment -> Set Windows XP x64 Build Environment (Debug/Retail) <- 目前不知道是哪一个
2) start the VC++ 2005 Express IDE run the VCExpress.exe file with the /USEENV swich: [your install dir of VC++ 2005 Express]\Common7\IDE\VCExpress.exe /USEENV This will clear out all default bin/lib/include path and add only those that the 'Set Windows XP x64 Build Environment (Debug/Retail)' batch file sets for you.
2) 启动 VC++ 2005 Express IDE 运行 VCExpress.exe 文件和 /USEENV 开关:[您的 VC++ 2005 Express 安装目录]\Common7\IDE\VCExpress.exe /USEENV 这将清除所有默认的 bin/lib/include路径并仅添加“设置 Windows XP x64 构建环境(调试/零售)”批处理文件为您设置的那些。
3) Open your application or create a new one.
3) 打开您的应用程序或创建一个新应用程序。
4) Edit the properties for the application ( Project -> Properties ) and change this settings to this values.
4) 编辑应用程序的属性( Project -> Properties )并将此设置更改为此值。
C/C++ -> General -> Debug Information Format : Program Database (/Zi) C/C++ -> Code Generation -> Basic Runtime Checks : Default Linker -> Advanced -> Target Machine : not set Linker -> Command Line -> Additional Options : /MACHINE:AMD64
C/C++ -> General -> Debug Information Format : Program Database (/Zi) C/C++ -> Code Generation -> Basic Runtime Checks : Default Linker -> Advanced -> Target Machine : not set Linker -> Command Line ->附加选项:/MACHINE:AMD64
now it should be able to compile for 64bit (I think I havn't forgotten anything)
现在它应该能够为 64 位编译(我想我没有忘记任何东西)
altough I got this error: error PRJ0002 : Error result 128 returned from 'C:\Program Files\Microsoft Platform SDK\Bin\mt.exe'.
虽然我收到了这个错误:错误 PRJ0002:从“C:\Program Files\Microsoft Platform SDK\Bin\mt.exe”返回的错误结果 128。
but solved it by copy the mt.exe that comes with the VC++ 2005 Express install to the PSDK/Bin dir, thus overwriting the PSDK/bin/mt.exe.
但是通过将 VC++ 2005 Express 安装附带的 mt.exe 复制到 PSDK/Bin 目录来解决它,从而覆盖 PSDK/bin/mt.exe。
Another thing I almost forgot. you maybe get this error described here: http://support.microsoft.com/?id=894573adding bufferoverflowU.lib to the project will solve that.
另一件事我几乎忘记了。您可能会在此处描述此错误:http: //support.microsoft.com/?id=894573 将 bufferoverflowU.lib 添加到项目将解决该问题。
NOTE: I havn't tested it anything yet just compiled a simple windows app and a console app and the TaskManager doesn't say *32 after the process as it would do if it was 32-bit. I don't know if it works with larger projects or anything because I got it working for like 10 minutes ago :)
注意:我还没有对它进行任何测试,还只是编译了一个简单的 Windows 应用程序和一个控制台应用程序,并且 TaskManager 在此过程后不会像 32 位那样显示 *32。我不知道它是否适用于更大的项目或任何东西,因为我在 10 分钟前就开始工作了:)
But I have a question about my newly created 64bit applications (just a simple "hello world" window created by the built in wizard) how can I be sure that it is really 64 bit? the Taskmanager says it is because it doesn't have the *32 but is that enough proof?
但是我有一个关于我新创建的 64 位应用程序(只是一个由内置向导创建的简单的“hello world”窗口)的问题,我如何确定它真的是 64 位的?任务管理器说这是因为它没有 *32 但这足以证明吗?
EDIT: you may need to copy the msvcrtd.dll & msvcp60d.dll from PSDK\NoRedist\Win64\AMD\ to where they belong (don't really know) I put them in Windows\System32
编辑:您可能需要将 msvcrtd.dll 和 msvcp60d.dll 从 PSDK\NoRedist\Win64\AMD\ 复制到它们所属的位置(我真的不知道)我把它们放在 Windows\System32
information take from http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvc/thread/d0770dde-56e5-4a28-acb0-30908c0f7ebdRead this also :
信息取自http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvc/thread/d0770dde-56e5-4a28-acb0-30908c0f7ebd另请阅读:
http://www.codeproject.com/KB/system/64BitOSAndPortingIssues.aspx
http://www.codeproject.com/KB/system/64BitOSAndPortingIssues.aspx
回答by Edwin Tai
you can compile it directly in vs2005 or 2008 because of the attribute "any CPU" but cancel the attribute "com seen" if you have perhaps you should copy it to system32 instead of 64 and then RegAsm it
您可以直接在 vs2005 或 2008 中编译它,因为属性“任何 CPU”,但取消属性“com seen”,如果您可能应该将其复制到 system32 而不是 64 然后 RegAsm
回答by dbd
Select propeties on your project i solution explorer. Under Build - Platform, choose "Any CPU".
在您的项目 i 解决方案资源管理器上选择属性。在构建 - 平台下,选择“任何 CPU”。