A question regarding VS project setting
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 13 of 13

Thread: A question regarding VS project setting

  1. #1
    Join Date
    Jul 2005
    Posts
    910

    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.

  2. #2
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,634

    Re: A question regarding VS project setting

    If you set the dependencies all projects that are needed are built
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    http://www.microsoft.com/visualstudio/eng/downloads

  3. #3
    Join Date
    Feb 2002
    Posts
    4,640

    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

  4. #4
    Join Date
    Jul 2005
    Posts
    910

    Re: A question regarding VS project setting

    Quote Originally Posted by S_M_A View Post
    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.

  5. #5
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,977

    Re: A question regarding VS project setting

    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.
    Best regards,
    Igor

  6. #6
    Join Date
    Jul 2005
    Posts
    910

    Re: A question regarding VS project setting

    Quote Originally Posted by Igor Vartanov View Post
    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.

  7. #7
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,977

    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.
    Last edited by Igor Vartanov; June 13th, 2012 at 06:10 PM.
    Best regards,
    Igor

  8. #8
    Join Date
    Jul 2005
    Posts
    910

    Re: A question regarding VS project setting

    Quote Originally Posted by Igor Vartanov View Post
    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.

  9. #9
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,634

    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...
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    http://www.microsoft.com/visualstudio/eng/downloads

  10. #10
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,977

    Re: A question regarding VS project setting

    Quote Originally Posted by LarryChen View Post
    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
    Best regards,
    Igor

  11. #11
    Join Date
    Jul 2005
    Posts
    910

    Re: A question regarding VS project setting

    Quote Originally Posted by Igor Vartanov View Post
    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.

  12. #12
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,634

    Re: A question regarding VS project setting

    Quote Originally Posted by LarryChen View Post
    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.
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    http://www.microsoft.com/visualstudio/eng/downloads

  13. #13
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,977

    Re: A question regarding VS project setting

    Quote Originally Posted by LarryChen View Post
    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).
    Last edited by Igor Vartanov; June 15th, 2012 at 02:43 AM.
    Best regards,
    Igor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center