Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Visual Studio 2005 not generating .obj files

Posted on 2013-01-30
3
Medium Priority
?
389 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 25

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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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…

972 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