Solved

Visual Studio 2005 not generating .obj files

Posted on 2013-01-30
3
352 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
Comment Utility
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
Comment Utility
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
Comment Utility
Self-explanatory
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
VS2015 compilation and missing DLLs 9 96
Example of WebAPI 7 29
Slow process to read Excel 15 99
convert char array to number in c 5 77
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 most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now