Menu

Answer generation of DLL import library

Anonymous

Generating an import library for a DLL

Import libraries for our toolchain can be generated by .def files and by using the dlltool provided by binutils.

If you need to generated a .def file for your DLL, then you can use the [gendef] tool - provided by our project in mingw-w64-tools/ folder - or the pexport tool.

For generation of the import library by the .def file use the following command.

[toolchain-prefix-]dlltool -k --output-lib <your-lib-name> --def <your-def-file>

With multilib one might need to use options '--as' and '--as-flags':

-S --as <name>            Use <name> for assembler.
-f --as-flags <flags>     Pass <flags> to the assembler.

One should check that produced library contains function calls you expect. One way to do this is use corresponding objdump.

[toolchain-prefix-]objdump -t <your-lib-name>

You should see clear text names for the functions. Example line from 64B OpenCL.dll:

7(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 clGetPlatformInfo

Back


Related

Wiki2: FAQ
Wiki2: gendef