Skip to content

How to generate import library for MinGW

Elethom edited this page Mar 22, 2021 · 9 revisions

Microsoft Windows has this thing called "import libraries" (*.lib). You don't need it in MinGW because the ld linker from GNU Binutils is smart, but MSVC still needs it for linking.

The .lib file is generated from a .def file. You should be see it in your exports directory: cd OPENBLAS_TOP_DIR/exports

Edit libopenblas.def. Insert LIBRARY libopenblas.dll to the head, as following. (This can probably be automated in gensymbols, but why are we to judge?)

LIBRARY libopenblas.dll

EXPORTS

   caxpy=caxpy_  @1

   caxpy_=caxpy_  @2

       ...

Then, generate the import library: dlltool -d libopenblas.def -l libopenblas.a