Rob190,
I'm afraid you overlooked or did not understand my previous post...
All I did was to use the wizard to create 3 empty projects: two applications and one static library. |
No friend, what you really did is create 3 independent solutions (each for one project), and now wonder why they don't work as if inside single solution.
What you expect will work only if all projects are within same solution.
The behavior that you want achieve is not possible because that applies only if all projects are within same solution, but you broke into 3 independent pieces.
As you can see there are 2 ways to add\create new projects:
1. File ->
new -> project (creates new solution)
2. Right click existing solution ->
add -> new project (uses existing solution)
HINT:
To avoid such problems in the future, add new project to same solution by right click on solution in VS and add new project (option 2 above),
you don't create new solution for each new project.
Secondly, I have no dependencies between project 1 and project 2 |
No you don't but both projects have dependency on same LIB project, what happens is that now each project modifies the
lastbuildstate file of the LIB project which by design triggers build for the LIB project because last build was not initiated by the same project.
Thirdly, the lib.cpp is being recompiled |
Ah yes, I overlooked this, the LIB indeeds get rebuilt (compile + link),
however this does not change anything said so far.
Your build setup will not work and there is no answer to your question because that's not how things work in VS.
To fix this problem, you have only 2 options:
1. Explicit linking (allows you to have projects in it's own solutions)
2. Put all projects into same solution and VS will build the LIB just once (until modified)
Hint:
Option 1 is used when dealing with 3rd party libs.
Option 2 is used when you develop your own library.
If you really want to have projects in separate directory, no problem, Option 2 can handle that, but it's recommended to have project files within same solution folder.
EDIT:
For your convinience here is sample solution made of your projects, this is how you setup build system when developing your own library (this is option 2 discussed before)
https://1drv.ms/u/s!AhDrKQrnMQzuhAqPEBTvouNWj1Ak?e=yhyLcX