如何使用Visual Studio 2010编译64位的C DLL? [英] How to compile a C DLL for 64 bit with Visual Studio 2010?
问题描述
我有一个用C语言用源代码编写的DLL。这是通用多边形剪切器的代码(如果您感兴趣)。我通过首页提供的C#包装器在C#项目中使用它。
I have a DLL written in C in source code. This is the code for the General Polygon Clipper (in case you are interested). I'm using it in a C# project via the C# wrapper provided on the homepage. This comes with a precompiled DLL.
由于切换到具有Visual Studio 2010和Windows 7 64位的64位开发计算机,该应用程序将不再运行。这是我得到的错误:
Since switching to a 64bit Development machine with Visual Studio 2010 and Windows 7 64 bit, the application won't run anymore. This is the error I get:
试图加载格式错误的程序。
An attempt was made to load a program with an incorrect format.
这是因为 DLLImport
使用了32位 gpc.dll
,因为我是从网上找到的东西中收集的。
This is because of DLLImport
ing the 32bit gpc.dll
, as I have gathered from stuff found on the web.
我认为,如果我将DLL重新编译为64bit,一切都会消失,但是对于爱我的人找出解决办法。我的C技能很基本,因为我可以使用GNU工具编写C程序,但是没有使用各种编译器/处理器/ IDE等的经验。
I assume this will all go away if I recompile the DLL to 64bit, but can't for the love of me figure out how to do so. My C skills are basic, in that I can write a C program with the GNU tools, but have no experience with various compilers / processors / IDEs etc.
我相信我可以将其移植到C#。我的意思是,我相信自己能真正实现目标。但我不希望这样做,因为这是我需要编译器为我完成的大量工作;)
I believe I could port this to C#. By that I mean I trust myself to actually pull it off. But I'd prefer not to, since it is a lot of work that I'd prefer a compiler to do for me ;)
推荐答案
就像创建一个新平台一样简单:
It could be as easy as creating a new platform:
- 打开项目的属性页(ALT + ENTER)
- 在右上角的下拉菜单中选择平台 x64
- 如果平台尚不存在,请创建一个新平台
- 请确保您在构建时检查的是正确的工件,因为您现在可能具有不同的输出目录。
这篇关于如何使用Visual Studio 2010编译64位的C DLL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!