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.
To create a static library project in Visual StudioOn the menu bar, choose File > New > Project to open the Create a New Project dialog. At the top of the dialog, set Language to C++, set Platform to Windows, and set Project type to Library.
Yes, the Core and Utils code will be duplicated. Instead of building them as static libs you can build them as dlls and use anywhere. Save this answer.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With