A question regarding VS project setting
I have a solution containinging multiple projects. If I change a file in a project and then select Build/Build solution, sometimes the break point set in that file won't be hit. I have to rebuild that project which contains the changed file and select Build/Build solution, then the break point will be hit. Why? Thanks.
Re: A question regarding VS project setting
If you set the dependencies all projects that are needed are built
Re: A question regarding VS project setting
Like SMA said, you need to set the build order of the sub-projects (which project depends on which).
Viggy
Re: A question regarding VS project setting
Quote:
Originally Posted by
S_M_A
If you set the dependencies all projects that are needed are built
But when I select Build/Build Solution, the compiler should know which project has been changed, as the result, all of the projects that depend on that project should be also compiled, right? Thanks.
Re: A question regarding VS project setting
Quote:
all of the projects that depend on that project should be also compiled, right?
They will, right. But build order matters. This is what dependency is about. :)
Re: A question regarding VS project setting
Quote:
Originally Posted by
Igor Vartanov
They will, right. But build order matters. This is what dependency is about. :)
Okey, let's say I have projects in the build order as A, B, C, D, E. At one point, I change project C. I assume when I select Build/Build Solution, the compiler will build the projects in the order as A, B, C. It should be perfectly fine, right? But how come a break point set in project C won't be hit in this scenario? Thanks.
Re: A question regarding VS project setting
This indicates that debug database has no corresponding entry for the line. This may be due to changes in D or E, for example. Or A or B depend on C but occur rebuilt with older version of C due to wrong build order.
Re: A question regarding VS project setting
Quote:
Originally Posted by
Igor Vartanov
Or A or B depend on C but occur rebuilt with older version of C due to wrong build order.
Can you explain how wrong build order can possibly cause A or B rebuilt with oder version of C? I didn't change the build order whatsoever. The build order always stay what it is. Thanks.
Re: A question regarding VS project setting
Frankly, why spending time on arguing about it? I have never ever experienced the issue you describe in a multi-project solution where the dependencies are properly set. If they are not set, well sooner or later the issue show up...
Re: A question regarding VS project setting
Quote:
Originally Posted by
LarryChen
Can you explain how wrong build order can possibly cause A or B rebuilt with oder version of C? I didn't change the build order whatsoever. The build order always stay what it is. Thanks.
I thought it's kinda obvious.
- You have A.exe dependent on B.lib, when A builds first
- You have some B.lib already built to the moment
- You make change in B sources and put a break point on a newly added line
- You run Build All which starts with building A
- A gets built linking with old B.lib, because old B.lib exists, and B has not been built yet with new changes
- B gets built fine, but newly added lines are not in A.exe
- You run A.exe, but break point never hits, because A has been built with old version of B having no those lines in
Re: A question regarding VS project setting
Quote:
Originally Posted by
Igor Vartanov
I thought it's kinda obvious.
- You have A.exe dependent on B.lib, when A builds first
- You have some B.lib already built to the moment
- You make change in B sources and put a break point on a newly added line
- You run Build All which starts with building A
- A gets built linking with old B.lib, because old B.lib exists, and B has not been built yet with new changes
- B gets built fine, but newly added lines are not in A.exe
- You run A.exe, but break point never hits, because A has been built with old version of B having no those lines in
But since B has changed, how come B is NOT compiled before A since A depends on B?
Let's say I have a solution containing projects A, B, C, D, E which are in the build order. If I change C and then build the solution, the compiler should detect C's changes. Since build order is preset as A, B, C, D, E, so compiler should compile A, B and then C. And then the linker should eventually link the objects of A, B and C with the executable. This is what I assume how build works. My question is how 'd it happen that the linker is trying to link old version of C object with the executable? Thanks.
Re: A question regarding VS project setting
Quote:
Originally Posted by
LarryChen
But since B has changed, how come B is NOT compiled before A since A depends on B?
That's what's happening if you set the dependencies.
Re: A question regarding VS project setting
Quote:
Originally Posted by
LarryChen
But since B has changed, how come B is NOT compiled before A since A depends on B?
Let's say I have a solution containing projects A, B, C, D, E which are in the build order. If I change C and then build the solution, the compiler should detect C's changes. Since build order is preset as A, B, C, D, E, so compiler should compile A, B and then C. And then the linker should eventually link the objects of A, B and C with the executable. This is what I assume how build works. My question is how 'd it happen that the linker is trying to link old version of C object with the executable? Thanks.
Larry, this is the very point where you're wrong. Build goes per project in your solution. Every project builds completely before building next project. This cannot be done other way just because some project may depend on other project build resultant binary (.lib, or .dll, or even .exe in some cases).