本文是小编为大家收集整理的关于在Visual Studio中自动生成一个DLL .DEF文件?的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。
问题描述
有什么方法可以自动生成Visual Studio中DLL的DEF文件?我一直以前只是手动创建它们,但是有一个更简单的方法.
推荐答案
我在这里找到了一个为您生成.def文件的地方:其他推荐答案 简单地说:编写一个适合您需求的脚本.我是一个在某些地方创建一个小的perl脚本,以创建.def file 从创建现有的dll,然后将其用于从中创建导入库(.lib). 没有读取工具可以为您执行的读取工具的原因是,涉及的任何工具都无法猜测或以某种方式确定您要导出的功能,变量或常数或类别的函数,变量或类别.<<<<<<<< 您可能知道模块定义文件允许您更改内部名称在导出表中显示的方式,允许按序数(而不是名称)或名称和序数导出.当然,它们还允许多次导出功能(例如,由于旧名称而引起的旧名称,而较新的名称现在遵循一些约定). 另请参阅这个问题.您会注意到答案还涉及自定义脚本.在这种情况下,这种要求显然只是脱词和导出任何非静态功能的名称. 请参阅此处的演示项目的答案:其他推荐答案
问题描述
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.
推荐答案
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.
其他推荐答案
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.
其他推荐答案
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.