在 Visual Studio 中自动生成 DLL .DEF 文件?

发布于 2024-08-20 13:33:06 字数 72 浏览 5 评论 0原文

有没有办法在 Visual Studio 中自动生成 DLL 的 DEF 文件?我以前总是手动创建它们,但一定有一种更简单的方法。

Is there any way to automatically generate the DEF file for a DLL in Visual Studio? I've always just manually created them before, but there's gotta be an easier way.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

幸福%小乖 2024-08-27 13:33:06

我在这里找到了一个为您生成 .DEF 文件的地方: expdef - def 文件生成器< /a>

这非常有效,除了函数和符号的方法名称之外,您还可以生成一个选项列表。

I have found a place to generate the .DEF file for you here: expdef - def file generator

This works amazing and has a list of options you could also generate besides the method names of the functions and symbols.

舂唻埖巳落 2024-08-27 13:33:06

简而言之:编写适合您需求的脚本。我在某些地方创建了一个小型 Perl 脚本,用于从现有 DLL 创建一个 .def 文件,然后将该文件用于创建导入库 (.lib) 从中。

没有读取即用工具可以为您执行此操作的原因是,所涉及的工具都无法猜测或以某种心灵感应方式确定您想要导出哪些函数、变量、常量或类以及以哪些名称导出。

您可能知道,模块定义文件允许您更改内部名称在导出表中的显示方式,允许按序号(而不是名称)或按名称和序号导出。当然,它们还允许多次导出一个函数(例如,由于遗留支持目的而使用旧名称,而由于现在遵循某种约定而使用新名称)。

另请参阅此问题。您会注意到答案还涉及自定义脚本。在这种情况下,要求显然只是分解和导出任何和所有非静态函数的名称。

Simply put: write a script that suits your needs. I for one created a small Perl script at some to create a .def file from an existing DLL that would then be used to create an import library (.lib) from it.

The reason there is no read-to-use tool that does it for you is because none of the tools involved can guess or somehow telepathically determine which functions or variables or constants or classes you want to export and under which names.

As you may know module definition files allow you to alter how an internal name appears in the export table, allow to export by ordinal (instead of name) or by name and ordinal. Of course they also allow to export a function multiple times (e.g. an old name due to legacy support purposes and a newer one because it follows some convention now).

Also see this question. You will notice that the answer also involves a custom script. In this case the requirement is apparently only to demangle and export the names of any and all non-static functions.

残疾 2024-08-27 13:33:06

请参阅此处演示项目的答案:

https://stackoverflow.com/a/64302521/2338477

我已经包含了 python 脚本从静态库生成 .def 文件,但不幸的是它不适用于变量/数据。

See answer with demo project in here:

https://stackoverflow.com/a/64302521/2338477

I have included python script to generate .def file from static library, but that unfortunately does not work with variables / data.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文