Solved

Visual Studio 2005 not generating .obj files

Posted on 2013-01-30
3
369 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

Title # Comments Views Activity
WPF issue with Trigger 2 148
Header of docx file 17 145
Visual Studio hangs on running project 6 84
Finding Divisors 5 60
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
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…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

734 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