What does "Unexpected precompiled header error" mean? - c++

I was trying to build a simple solution involving a Windows and a Console application. After using the wizard to generate the code skeleton for the projects, I didn't add any code and just built the generated code. In both cases I got the same error:
1>c:\c\winpr\winpr\winpr.cpp(4) : fatal error C1859: 'Debug\winpr.pch' unexpected precompiled header error, simply rerunning the compiler might fix this problem
What is wrong, any thoughts?

There is a fix for Visual C++ 2008 SP1 compiler error C1859. You may download it here.
For details see this.

We had something similar at work all of a sudden, one day. Our problem was down to this
A simple PC restart done it for me anyway.

The link provided in the answer above is no longer available.
I was getting the same error and in my case the problem was due to a 'Windows Update' that required a restart (which I avoided the restart and kept getting this problem). But after the reboot the error was fixed.

Installing visual C++ 2008 SP1 fixed my issue.

Install this patch (KB976656 - Error message when you use the Visual C++ 2008 compiler: "fatal error C1859") to fix this issue:
http://thehotfixshare.net/board/index.php?autocom=downloads&showfile=11640

If you have #include<stdfafx.h>, try commenting it out like so //#include<stdfafx.h> as it may be the culprit behind your errors.

Related

Why is OpenDDS failing to compile?

My friend is trying to compile OpenDDS from here:
OpenDDS Insall Directions
I have no code.. but i need this to make pastebin work?
She has followed that link to a T. And it produces these errors:
Errors
Here is the full output from Visual Studio:
Output
The interesting part:
I can compile it just fine using the instructions from that link in the top. I have done more coding than she, so something is installed that is allowing it to compile without issue, she has a clean install of Visual Studio Community, I have Visual Studio Enterprise (Both 2019) - I do not think the versions should matter, but shared for better understanding.
From what I can gather from the errors, there is a problem locating files on her machine, and not mine. Why it can't find files? I have no idea... I am really confused with why it works for me not her.
I even went and made a VirtualBox Machine with windows 10 on it, and I get the same errors there.
Any and all help is super appreciated, thank you!
This was fixed in this PR: https://github.com/objectcomputing/OpenDDS/pull/1701, but that hasn't made it into a release yet. I can't comment in the comment chain above, but dxiv is correct that this is caused by an include dependency that broke in VS2019. It's only in the dds/DCPS/Serializer.h header though, so just having your friend change that file to how it is in the PR should allow it to build.

Error code 31 returned from mt.exe when building C++ projects in Visual Studio 2013 [duplicate]

I ran into this problem today while migrating a VS2008 solution to VS2010. The problem occurred in either of the following scenarios:
Rebuild Solution
Clean followed by Build Solution
If I did a second Build after either of these, the problem did not show up. Using Google, all I really came up with was year-old blogs from Microsoft saying they are unable to reproduce the problem, or that it is fixed in a future release.
The best thing I found was here: Mikazo Tech Blog: Solve MT.exe Errors in Visual Studio 2010
In the above article it said that the problem is related to Manifest generation, and that the solution is to turn off Manifests in settings under Linker-->Manifest. I don't need Manifests for this project, but I still wasn't satisfied.
I have solved this, and am simply going to answer my own question, because I haven't found this specific error (code 31) on StackOverflow.
WARNING: This exact error can also happen as a result of having a Windows Explorer window open in the folder containing the *.exe which you are currently attempting to build.
For example: Explorer open in /.../MyProj/Debug/ while trying to build the Debug version of your code in Visual Studio.
I was angry with myself for ~10min before realizing this.
Using process monitor and dbgview I discovered msmpeng (Microsoft Security Essentials) was accessing the file, just when mt.exe wanted to have it exclusively. Excluding the development directory solved the problem.
It is still a workaround of course.
In my projects, the Intermediate and Output directories were set to:
Intermediate Dir : $(Configuration)\
Output Dir : $(SolutionDir)bin\$(Configuration)\
Under C/C++-->Output Files, I had the following:
ASM List Location : $(IntDir)\
Object File Name : $(IntDir)\
Program Database File Name : $(OutDir)\$(TargetName).pdb
Under Linker-->Manifest File, I had:
Manifest File : $(IntDir)$(TargetName)$(TargetExt).intermediate.manifest
The cure was to remove the trailing \ from my C/C++-->Output Files section (because it's already part of those variables):
ASM List Location : $(IntDir)
Object File Name : $(IntDir)
Program Database File Name : $(OutDir)$(TargetName).pdb
Normally, the double-up of using $(IntDir) or $(OutDir) with a trailing \ doesn't seem to cause trouble, even though it's bad practice. I can't remember now whether I did it by accident or if the conversion process did it, but for whatever reason, it seems to have been messing up MT.exe.
I hope this is useful to anyone else who encounters this problem. Your settings may well be different, but consider that it may be related to improperly formed filenames.
Try turning off Windows Defender (or possibly other anti-virus related software). Windows Defender is known to lock files because MT.EXE runs after the linker is finished. WD jumps in the middle to check up on the newly built EXE and locks it up for the MT.EXE.
Giving credit to https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/c5a3e2c3-fbf4-4268-a551-8cee195be586/test-case-13-for-vista-certification?forum=windowscompatibility, I found this was resolved by fixing the '-' character in the post build commandline. I believe some bad copy/paste efforts have replaced a hyphen with a dash.
deleting the "program debug database" in "debug" folder worked for me.
This problem happened when I was running the .exe in the debug folder on high priority.
Run VS as administrator. It solved the problem for me.
I have a project (*.sln) written in visual studio c 8.0. It was migrated to VC10 recently. When I choose the "Release mode", it was compiled sucessfully. But if I choose "Debug mode", the error " MSB6006 mt.exe code 31" happened.
I found that, in the debug mode, it used a wrong sub-project to startup.
After fixing the startup sub-project, it goes fine so far.
---- new status ---
This won't fix the problem. It just makes the problem disapear temporalily by rebuilding-all. Also, there are other faults caused by the migration. The "resources.h" is missed from the new project and the "winres.rc" is shorten.
In my case it was a problem with TortoiseGit. Removing Debug and Release folders from the GIT repository solved the problem.
Check if you have any anti-virus software like AVG. Exclude the manifest files in the anti-virus software exclusion list.
Look for an MSB8012 warnings. Likely you have a different output specification for the C++ output value and the Linker Output value.
Try Sysinternals/Procmon and filter on process = "mt.exe". It might tell you that a build input cannot be found.

Visual Studio 2013: Error MSB4014: The build was aborted because of an internal failure

After using VS08 without any problem for several months, I've decided to install VS2013. Unfortunately, VS won't stop crashing after Building/Rebuilding/Cleaning a simple project.
I have just created an empty project with a main.cpp file outputing "Test", but it keep posting this error.
I have seen some posts about it on VS08 and a Microsoft hotfix for it but nothing on VS2013, and nothing that solved my problem.
I've tried uninstalling/reinstalling VS2013
What would cause this issue?
According to Hanselman's blog, this error might be caused by an invalid character in your PATH variable. BuildParameters, included in your error log, is only called when reading the environment variables, so it seems that your PATH variable got corrupted somehow.

Why won't Allegro initialize?

I tried installing allegro 5 to code blocks, but even though it seems the program compiles it won't initialize. I get an error saying the application failed to start because allegro-5.0.9-monolith-md-debug.dll was not found. It also says re-installing may help, but I've tried that several times already. I tried following online tutorials, but I still get this error. Am I doing something wrong? Please help.
Copy allegro-5.0.9-monolith-md-debug.dll into the same directory as your source code. I had this same exact problem. I was using Visual C++ 2010 express edition, paste it with the source not the .exe if you are running it from within the compiler, if you want to run it outside of the compiler it will need to in the same location as the .exe

Cryptic TFS Build Error - Bug?

Can anyone make any sense of this TFS build error? Googling produces few results and my research hasn't given me a solution.
Method not found: 'Void
Microsoft.TeamFoundation.TestManagement.Client.ModuleCoverage.set_Statistics(Microsoft.TeamFoundation.TestManagement.Client.CoverageStatistics)'.
For a previous build, where I was getting this same error, I changed Analyze Test Impact to False, and then the build worked. That's not working here though.
What does this even mean? Is it a bug? Does anyone know how to fix it?
My attempt at fixing the issue:
I did not get this exact error, but I got a similar error where built in methods were failing because of the wrong signature and missing methods, because someone installed Visual Studio 2012 on one of my servers. My guess is the new TFS Dlls that came with 2012 were GAC'd and took precedence over the 2010 dlls. I would verify this hasn't happened to you as well.
It appears that the error shown in the original question wasn't really the problem. We have now fixed this in two different solutions, two different ways.
In the first solution, the build succeeded by fixing the CA errors.
In the second solution, the build succeeded by fixing syntax in a post-build event.
I think the entire problem is that an error was showing that wasn't really the problem. I'm not sure why that method not found error would be the symptom, but it wasn't the cause.
Actually, that method not found error still shows in the build log, but the build succeeds, so sometimes you just have to move on...
I was getting this error in the webview but not in the build log file and the build was not failing. Applying the TFS 2010 SP1 patch fixed it for me.