如何使用 Visual Studio 2010 编译 64 位的 C DLL? [英] How to compile a C DLL for 64 bit with Visual Studio 2010?

查看:46
本文介绍了如何使用 Visual Studio 2010 编译 64 位的 C DLL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用 C 语言编写的 DLL 源代码.这是 General Polygon Clipper 的代码(以防万一感兴趣).我通过主页上提供的 C# 包装器在 C# 项目中使用它.它带有一个预编译的 DLL.

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 DLLImporting the 32bit gpc.dll, as I have gathered from stuff found on the web.

我认为如果我将 DLL 重新编译为 64 位,这一切都会消失,但我无法弄清楚如何这样做.我的 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屋!

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