Project DLL does not generate .exp and .lib files

So, I have C ++ - a solution that contains 3 projects (2 DLLs and 1.exe).

Here is a view of the main dependencies:

Application β†’ DLL2

Application β†’ DLL1

DLL2 β†’ DLL1

The problem is that DLL2 (when it is created) generates .dll, but does not generate .lib and .exp. I need to reference DLL2 correctly in the Application project. However, DLL1 creates these files, and I compared the parameters of DLL1 with DLL2, and I can not find what the difference is.

+6
source share
3 answers

The problem was that DLL2 had only .h files and did not contain any of the associated .cpp files. Therefore, in the IDE, there was no need to create a .lib file.

+4
source

A simple explanation for this is that you simply forgot to export anything. The compiler does not create a .lib / .exp file if there is no export. You can verify this by running dumpbin.exe /exports in the DLL. With the expectation that you do not see anything.

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

+9
source

I just discovered another way to trigger the same thing. I moved some routines that I developed and tested as service procedures in another DLL into my own DLL. Since this step was planned before I wrote the first line of code, they were not marked for export and therefore used this default convention for the project, __cdecl. When I built the library, the build environment did not create the .LIB file. After some research and inspired by the mention of __declspec (dllimport) in this section, I realized that although I moved the declarations to the template header file generated by the New Project Wizard, I forgot to insert the name of the generated macro call into the prototypes.

With the specified calling convention, both in the header and in the CPP files containing the implementations, I received the expected .LIB file.

0
source

All Articles