I have two dll modules. Module A and B. "A" call's function "B". And "B" calls function "A" to place result. "B" dependes from "A", "A" depends from "B". When i compiling (clean) project - i have a problem. (I have to remove module dependency - comment some lines - compiling "A" -then "B" then uncomment lines, add dependency and again compiling "A")
Asked
Active
Viewed 230 times
1
-
Header files should solve that problem. – sharptooth Jul 15 '11 at 07:49
-
Hm... I including all header files in each projects. That is not problem compiling another if one of them already exists. The problem is how resolved compilation cyclic dependency for clean project. – Stepchik Jul 15 '11 at 08:34
-
Is the error reported by the compiler or by the linker? – Dan Jul 15 '11 at 08:54
1 Answers
1
First of all, you really should try as hard as possible to not produce circular dependencies. There are a lot of ways around, and which one is best for you depends on the exact nature of your depedencies.
- merge the two DLLs into one
- use a callback mechanism (function pointers, some interface defined in B) to pass the dependency at run time
e.g.
callFunctionInB(args, callbackInA)
-
If you MUST have the circular dependencies, you will have to wade into the toolchain a bit deeper, starting here. In short, it is possible to create a stub .LIB
file you need to link to a DLL without actually compiling the DLL.
Reference: circular dependencies between dlls with visual studio