Automatically generate a DLL .DEF file in Visual Studio?
Asked Answered
B

3

12

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.

Blumenthal answered 1/2, 2010 at 16:26 Comment(1)
Yes, it's possible with newest version of the CMake. Look at my answer for clarification: https://mcmap.net/q/237147/-export-all-symbols-when-creating-a-dllKingsly
I
5

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.

Idolla answered 2/8, 2013 at 15:49 Comment(0)
T
1

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.

Two answered 17/5, 2012 at 0:13 Comment(0)
A
0

See answer with demo project in here:

https://mcmap.net/q/1011982/-generate-def-from-lib

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

Archiphoneme answered 11/10, 2020 at 9:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.