B
barias
Although circular dependencies are something developers should normally
avoid, unfortunately they are very easy to create accidentally between
classes in a VS project (i.e. circular compile-time dependencies). But
then I started wondering how "easy" it would be to similarly make a
NON-RUNTIME circular dependency between (implicitly linked) DLLs.
Indeed authors like John Lakos, who focus on compile/link-time
dependencies (not run-time), tell us to avoid such circular
dependencies between "packages" (i.e. libraries). But to my surprise,
evidently it isn't possible to create a circular library dependency
even if you try...
Tonight I tried to make a circular dependency by creating two Win32
console DLLs in a new VC++ solution, and attempted to make both have a
(implicit link) dependency on the other. But no matter how I tried, in
the end I always got a linker error about missing symbols - because DLL
'A' needed the type library of DLL 'B', which did not exist yet because
DLL 'B' needed the type library of DLL 'A'. A similar problem occurred
if I made both projects just static libraries (instead of DLLs).
In the end, I concluded that to make the circular dependency I would
need to involve some kind of externalized interface descriptions - such
as IDL (e.g. CORBA?). But if I used IDL in that fashion, I figure I
would end up with something that is more akin to circular runtime
dependency rather than a non-runtime dependency (and even then, it may
no longer qualify as truly circular).
Can anyone give me an example of how DLLs (or even static LIBs) can get
involved in a circular dependency? I'm scrutinizing this topic because
authors like Robert Martin or John Lakos ("Large Scale C++") talk about
how "packages" (aka libraries) should be forced away from cyclical
dependencies. Well, why make all that effort of preaching against
circular package/library dependencies, if its not even possible to make
such circular dependencies in the first place?
avoid, unfortunately they are very easy to create accidentally between
classes in a VS project (i.e. circular compile-time dependencies). But
then I started wondering how "easy" it would be to similarly make a
NON-RUNTIME circular dependency between (implicitly linked) DLLs.
Indeed authors like John Lakos, who focus on compile/link-time
dependencies (not run-time), tell us to avoid such circular
dependencies between "packages" (i.e. libraries). But to my surprise,
evidently it isn't possible to create a circular library dependency
even if you try...
Tonight I tried to make a circular dependency by creating two Win32
console DLLs in a new VC++ solution, and attempted to make both have a
(implicit link) dependency on the other. But no matter how I tried, in
the end I always got a linker error about missing symbols - because DLL
'A' needed the type library of DLL 'B', which did not exist yet because
DLL 'B' needed the type library of DLL 'A'. A similar problem occurred
if I made both projects just static libraries (instead of DLLs).
In the end, I concluded that to make the circular dependency I would
need to involve some kind of externalized interface descriptions - such
as IDL (e.g. CORBA?). But if I used IDL in that fashion, I figure I
would end up with something that is more akin to circular runtime
dependency rather than a non-runtime dependency (and even then, it may
no longer qualify as truly circular).
Can anyone give me an example of how DLLs (or even static LIBs) can get
involved in a circular dependency? I'm scrutinizing this topic because
authors like Robert Martin or John Lakos ("Large Scale C++") talk about
how "packages" (aka libraries) should be forced away from cyclical
dependencies. Well, why make all that effort of preaching against
circular package/library dependencies, if its not even possible to make
such circular dependencies in the first place?