Solved

Visual Studio 2005 not generating .obj files

Posted on 2013-01-30
3
361 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Slow process to read Excel 15 124
Windows Process running 3 54
max float value 3 41
How to properly read C++ console input into several variables with scanf 2 10
When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

776 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