DLL Project doesn't generate .exp and .lib file

10,716

Solution 1

The problem was that DLL2 had only .h files and no content in any of the associated .cpp files. So the IDE didn't see the neccesity of creating the .lib file.

Solution 2

The simple explanation for that is that you just forgot to export anything. The linker won't create a .lib/.exp file if there are no exports. You can verify this by running dumpbin.exe /exports on the DLL. With the expectation that you see nothing.

Use __declspec(dllexport) to export symbols from the DLL. Or a .def file.

Solution 3

I just discovered another way to cause the same thing to happen. I moved some routines that I developed and tested as service routines in another DLL into a DLL of their own. Since this move was planned before I wrote the first line of code, they weren't marked for export, and were, hence, using that project's default calling convention, __cdecl. When I built the library, the build environment didn't create a .LIB file. After some investigation, and inspired by the mention of __declspec(dllimport) in this topic, I realized that, although I moved the declarations into the template header file generated by the New Project Wizard, I forgot to insert the name of the generated calling convention macro into the prototypes.

With the calling convention specified, both in the header and the CPP files that hold the implementations, I got the expected .LIB file.

Share:
10,716
TurnsCoffeeIntoScripts
Author by

TurnsCoffeeIntoScripts

It is possible to commit no errors and still lose. That is not a weakness. That is life. (J.L. Picard) Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. (Arthur Conan Doyle)

Updated on June 04, 2022

Comments

  • TurnsCoffeeIntoScripts
    TurnsCoffeeIntoScripts almost 2 years

    So, I have a c++ solution which contains 3 project ( 2 DLL, and 1 .exe).

    here's the basic dependencies representation:

    Application --> DLL2

    Application --> DLL1

    DLL2 --> DLL1

    The problem I have is that DLL2 (when building it) does generate the .dll but doesn't generate the .lib and .exp I need to reference properly DLL2 in the Application project. However, DLL1 does generate these files and I've compared DLL1's settings to DLL2's, and I can't find what the difference could be.