1

For example, I have 3 modules : Module1.cpp/h Module2.cpp/h and Module3.cpp/h, Now I will build it as a static library named as Modules.lib

Then I will create another project that will be built as a DLL. Modules.lib will be imported to the project since some source code have dependencies on Modules.lib. I will build it as Library.dll

Now this Library.dll will be used by a Windows App. How can I use the functions/classes in Modules.lib that was imported in Library.dll? How can I also export the header files(Module1.h, etc). When I add them in the header file of the dll, there is an error. The dll header file cannot find the included header file.

I can't find a specific example for this. Please show me an example. Thank you very much.

  • Mark the functions/classes as exported/imported using a macro so that you can include the headers in the dll so that it then knows it needs to import them. And of course link the lib files – Neijwiert Mar 08 '18 at 11:00
  • you mean in Module1.cpp/h, I will mark the functions/class as exported/imported? – spartace1194 Mar 08 '18 at 11:09
  • See [this](https://stackoverflow.com/questions/26966095/using-dllimport-with-visual-c) question and then the answer of Pavel Oganesyan – Neijwiert Mar 08 '18 at 11:48
  • 1
    It is not likely that code that was written for a static library has its functions declared as __declspec(dllexport). So you need to use a .def file or the linker's /export option instead. – Hans Passant Mar 08 '18 at 12:55

0 Answers0