error C1854: cannot overwrite information formed during creation of the precompiled header in object file
Asked Answered
P

3

27
foo.cpp(33918) : fatal error C1854: cannot overwrite information formed 
during creation of the precompiled header in object file: 'c:\somepath\foo.obj'

Consulting MSDN about this gives me the following information:

You specified the /Yu (use precompiled header) option after specifying the /Yc (create precompiled header) option for the same file. Certain declarations (such as declarations including __declspec dllexport) make this invalid.

We are using dllexport and precompiled headers in this case. Have anyone encountered this before and know of any workaround? Any input to shed some light on this problem is greatly appreciated.

Thanks

Physicist answered 3/6, 2009 at 12:22 Comment(0)
P
49

I think you can find the answer here: http://social.msdn.microsoft.com/forums/en-US/vclanguage/thread/b3aa10fa-141b-4a03-934c-7e463f92b2a5/

Basically, you need to set the stdafx.cpp file to "Create Precompiled Headers" and all the other .cpp files to "Use Precompiled Headers"

Piglet answered 3/6, 2009 at 20:24 Comment(2)
Clean the solution after changing the options is recommended.Triplet
Do I get this correctly: the options dialog that looks like the project options isn't actually the project options but options for the source file that I have currently selected?Nubianubian
A
1

I had this problem too.

Make sure the precompiler header output file is set to the correct location. Mine was actually outputted to the right location, but there were problems reading it just because the path had a little artifact inside.

Alterant answered 28/12, 2010 at 14:28 Comment(0)
F
1

My solution was to carefully recheck all the precompiled header settings in not just the .exe project but all the dll projects also and recreate all the headers. After that the error was gone in the .exe compilation.

Firework answered 15/1, 2019 at 9:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.