Search code examples
c++dlllinkerdllimportdllexport

C++ 2 DLL's using eachother


Is it possible in c++ for 2 DLLs including eachother, because each of them uses eachother's classes(Well that's my plan), is this possible or not?


Solution

  • Yes, this is possible. Only you need to compile these dlls as a multi step process. To link a dll, you need a lib file from other dll. This means that you need:

    1. Create stub implementation of DLL1. This will produce a .lib file for DLL1.
    2. Link DLL2 with stub .lib pf DLL1.
    3. Link DLL1 with real .lib of DLL2.
    4. Relink DLL2 with real lib of DLL1.

    Also note that DLLs in general have C interface. You can export classes, but be ready to have set of dlls for each version of used compiler.