Advertisement

[MSVC] Dependencies

Started by March 13, 2001 03:58 AM
1 comment, last by gimp 23 years, 10 months ago
How do I use dependencies properly? My project consists of 2 static libraries Common and Graphics and one Test Rig console app. Is the idea of dependencies such that changes to common will cause test and graphics to be recompiled (as they use common''s code)? If so I guess that means every new project will need to be listed in each library it includes. Is that right? cb
Chris Brodie
Do you mean you want to avoid dependency, rather than use them??

And yes, if common changes, then all the projects using it needs to be recompiled.

A better alternative is to use a dll, so that the client''s code does not need recompiling if the interface (Header) do not change.

If you want to list the project that is using the lib, that is fine. But it gets hard when the lib is used by other people too.

The "best" way is to probably design the lib hierarchy properly so that there are not many static libs floating around.
Advertisement


Generally you want to make project A the dependency of project B when project A requires that project B be up to date.

This ensures that when you go to build project A the IDE will first check to see if project B is up to date before building A.

For example, you have a dll that implements the UI for your application (GUI.DLL).

GUI.DLL loads resources from RES.DLL at runtime in order to display properly. GUI.DLL includes RES''s resource.h file to have access to the resource ID''s so GUI.DLL compiles successfully.

However, if RES.DLL wasn''t compiled first to include the new resources that GUI dll will be requesting there will be a runtime error.

So, to avoid this problem, we make RES.DLL a dependency of GUI.DLL. So, when we build GUI.DLL, the IDE will first build RES.DLL if necessary.


This topic is closed to new replies.

Advertisement