开发者

Automatically generate a DLL .DEF file in Visual Studio?

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 g开发者_StackOverflow中文版otta 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜