views:

2915

answers:

3

I have a project that I'm building in C++ in Release mode in Visual Studio 2008 SP1 on Windows 7 and when I build it I keep getting:

fatal error C1047: The object or library file '.\Release\foobar.obj' was created with an older compiler than other objects; rebuild old objects and libraries.

The error occurs while linking.

I've tried deleting the specific object file and rebuilding but that doesn't fix it. I've also tried blowing away the whole release build folder and rebuilding but that also didn't fix it. Any ideas?

A: 

Check if you have a .pch (precompiled header) file somewhere in the project directory and erase it. then rebuild the project.
The best way to get a clean build is using Build->Clean or Build->Rebuild All

Edit: Another thing you can try that is pretty much fail safe is to recreate the project file in a new directory from only the source files.
If that works then you can incrementally compare the old project with the new one to see what does wrong.

shoosh
I tried deleting the precompiled header and also doing a build->clean but neither fixed it.
Jared
see new edit ...
shoosh
+2  A: 

I would suggest reinstalling VS 2008 SP1. Have you installed a different VS (e.g. VS Express) in the meantime? This is known to cause interference with an existing VS installation.

You could try checking the compiler and linker versions by running cl.exe and link.exe from the Visual Studio command prompt.

Tobiesque
I fixed this by reinstalling VS2008 SP1. What happened was I installed VS2008, then SP1, and then the Feature Pack. This created an inconsistency within the compiler, and reinstalling SP1 fixed it.
Jared
Glad you are up and running again!What seems to have happened is that the tools you used to create your objects were (slightly) older than the compiler provided objects you linked to.
Tobiesque
A: 

I had the same problem, but a straight up reinstall did not fix it. I was using the version I found here

https://www.dreamspark.com/Products/Product.aspx?ProductId=9

However, after trawling forums I found that installing VS2008 SP1 Express eliminates this problem. . . .

http://www.microsoft.com/downloads/en/details.aspx?displaylang=en&FamilyID=f3fbb04e-92c2-4701-b4ba-92e26e408569

You have to be careful which place you download VS2008 from as different versions of the same Express product are available for download.

learnvst