• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: How to break circular dependency between exe and dll

Resolved: How to break circular dependency between exe and dll

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

A C++ app has this exe/dll layout:
Main.exe, Framework.dll, PluginA.dll, PluginB.dll, ..., PluginN.dll
Both Main.exe and Framework.dLL provide functions to the Plugin#.dll.
The Plugins are depedent on Main.exe and Framework.dll, but not the other way around. Framework.dll depends on functions provided by Main.exe
Now, the problem is that there is a circular dependency between Main.exe and Framework.dll because Main.exe depends on 1 class in Framework.dll that it uses to manage the lifecycle of Framework.dll
So, in Main.exe, it would be something like this:
So, Main.exe depends on only 1 class from Framework.dll, but that’s enough to create their circular dependency.
Is there a way to still use that one Framework class from Main.exe while still breaking the circular dependency? Specifically, so that Main.exe doesn’t require the export library Framework.lib to build.

Answer:

The usual solution to this (although it’s usually used when two libraries have a circular dependency) is to create a ‘dummy’ version of one of them that defines all the relevant entry points but is not in any way dependent on the other and doesn’t need to link against it. That can then be used as a kind of ‘bootstrap’.
So in your case, you might create yourself a dummy_framework.cpp file that you can build to provide a framework.lib that main can then link against. Once you’ve done that, you can compile the ‘real’ framework to generate the ‘real’ framework.dll and you should then have a fully functional version of your app. (You can rebuild main if you want, but there shouldn’t actually be any need.)
This is all perfectly viable so long as the API of framework is reasonably stable, but even if it isn’t, you’ll get compiler or (more likely) linker errors when you try to build dummy_framework so you can update it then.

If you have better answer, please add a comment about this, thank you!

c++ dll visual-studio
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: In a Pinescript v5 Strategy why is my bool not working?

02/04/2023

Resolved: net::ERR_HTTP2_PROTOCOL_ERROR by http get request angular 15.2

02/04/2023

Resolved: How do I stop the command from happening if the requirements for it to work aren’t sert Discord.js

02/04/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.