Solved

Visual Studio 2005 not generating .obj files

Posted on 2013-01-30
3
362 Views
Last Modified: 2013-02-05
I have a Visual C++ solution in Visual Studio that contains two projects. One of the projects depends upon the output from the other project. So, for example, if the first project is called proj1 and the second proj2, proj2 has as a dependency in its Linker properties of proj1.obj. The C++ properties of proj1 specify the "Object File Name" as $(intDir)\ because there are multiple source files in the project, one of which is called proj1.cpp.  I am expecting Visual Studio to generate a .obj file for each of the .cpp files in proj1 when I run a build. I have also specified proj2 being dependent on proj1 in the project dependencies section of the solutions properties.

Every time I rebuild this solution the link of proj2 fails with the message "proj1.obj does not exist". If I then run the build (not rebuild, but just build, in other words, no clean) again, I see proj1 compiling again and it works fine. If I keep another window open during this whole process that is monitoring the $(IntDir) folder, I see a very peculiar thing happen. On the first rebuild, I see in the $(IntDir) folder, files created with the names of all the .cpp files in proj1 with an extension of .xdc, but there are no corresponding .obj files, which is why the link of proj2 fails. If I then run the build again, without cleaning, I see on the second pass the .obj files created and therefore the link of proj2 works.

I can never get the first rebuild to work, does anybody have any insight into why this happens?
0
Comment
Question by:nirvanastorage
  • 2
3 Comments
 
LVL 24

Expert Comment

by:chaau
ID: 38837815
I think you need to setup Project Dependencies. In VS2005 right click on your proj2 in the Solution Explorer and Select Project Dependencies. Then check all the projects that it depends on (in your example it will be proj1). If you have more projects do it for each of them.

You will then be able to see the Build Order. If the order is different to what you expect, you need to change the dependencies. You need to make sure that the proj1 is always built first.

Once you do this, the compiler will always wait till the proj1 compilation finishes before proceeding to proj2
0
 

Accepted Solution

by:
nirvanastorage earned 0 total points
ID: 38837861
I figured it out and it was really very simple. The Intermediate Directory I was using was the same for both projects and therefore the rebuild cleaned that folder in  between the two compilations, erasing the results of the proj1 build! When I changed the intermediate directory for the second project to a different folder than the intermediate directory of the first project, everything worked as expected.
0
 

Author Closing Comment

by:nirvanastorage
ID: 38854292
Self-explanatory
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question