I don't know at which point it stopped working, since I've been using Code::Blocks and MinGW for the last month or so. Nonetheless, almost all of my MSVC projects (and new ones as well) have stopped working altogether now that I opened up Visual Studio again, and every time I try to build them I get hundreds of errors in the Windows API headers.
The first and most common (list of many) problems I get is coming from windows.h, after which inclusion I get this:
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\winnt.h(3606): warning C4103: 'c:\program files (x86)\microsoft visual studio 10.0\vc\include\winnt.h' : alignment changed after including header, may be due to missing #pragma pack(pop)
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\winnt.h(3908): warning C4103: 'c:\program files (x86)\microsoft visual studio 10.0\vc\include\winnt.h' : alignment changed after including header, may be due to missing #pragma pack(pop)
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\winnt.h(4006): warning C4068: unknown pragma
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\winnt.h(4012): warning C4068: unknown pragma
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\winnt.h(4019): warning C4068: unknown pragma
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\winbase.h(1482): error C2144: syntax error : 'void' should be preceded by ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\winbase.h(1482): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\winbase.h(1483): error C2144: syntax error : 'void' should be preceded by ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\winbase.h(1483): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\winbase.h(1483): error C2086: 'int DECLSPEC_NORETURN' : redefinition
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\winbase.h(1482) : see declaration of 'DECLSPEC_NORETURN'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\winbase.h(1543): error C2144: syntax error : 'void' should be preceded by ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\winbase.h(1543): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\winbase.h(1543): error C2086: 'int DECLSPEC_NORETURN' : redefinition
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\winbase.h(1482) : see declaration of 'DECLSPEC_NORETURN'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\rpcdce.h(369): error C2144: syntax error : 'void' should be preceded by ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\rpcdce.h(369): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\rpcdce.h(369): error C2086: 'int DECLSPEC_NORETURN' : redefinition
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\winbase.h(1482) : see declaration of 'DECLSPEC_NORETURN'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\rpcdcep.h(89): error C3646: 'I_RpcAllocate' : unknown override specifier
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\rpcdcep.h(89): error C2091: function returns function
...
etc. etc. (full compilation output here)
This is similar, if not the same problem, to some I've found over the web, but still couldn't find any suitable solution out of:
http://www.jenkinssoftware.com/forum/index.php?topic=4877.0;wap2
http://ogre3d.org/forums/viewtopic.php?f=2&t=26302
https://social.msdn.microsoft.com/Forums/vstudio/en-US/0c97c9ed-c6a0-4f35-8bbf-33203e227f68/setting-up-windowsh-not-found?forum=vcgeneral
https://social.msdn.microsoft.com/Forums/vstudio/en-US/6cc0cfe6-2c59-4925-bdda-2920a0f7245b/big-time-problems-with-headers?forum=vclanguage
https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/06ca7ef8-6567-4968-99d3-d989cdcb1b8c/help-errors?forum=vcgeneral
http://irrlicht.sourceforge.net/forum/viewtopic.php?f=1&t=17147
http://forums.codeblocks.org/index.php?topic=4508.0
https://www.c-plusplus.net/forum/167678-full (German link)
https://www.spieleprogrammierer.de/11-hilfe-zum-buch-3d-spieleprogrammierung-von-david-scherfgen/3719-mal-wieder-fehler/ (German link)
https://zakimirza.wordpress.com/2007/03/04/setting-up-sdl-opengl-in-visual-studio/ (in a comment under the article)
It also quite reminds me of the problems I had when (dumbly) trying to compile from MSVC using the MinGW inclusions/libraries some time ago - though everything was still working properly at that point - so the best I can think of, it might be a similar issue, as in the headers became incompatible for some reason. Therefore, I thought, maybe I've installed a Win64 version over them without realizing?
I currently have MS Visual Studio 2010 Express, MS Visual Studio 2013 Express, Code::Blocks (with MinGW) and DevC++ installed. The only thing that changed in this period is that I tried out VS 2010 Ultimate (uninstalled shortly later after the trial expired) to try out some extensions, but everything worked just fine in the meanwhile, I don't know why it suddenly stopped working.
I've tried to uninstall and reinstall MSVC, Windows SDK and the DirectX SDK, but nothing worked. The environmental variables look fine, but maybe I haven't checked properly.
All the projects are in the same working state I've left them in, the environment being Win32 and all the inclusion paths being the same as before.
I really have no clue as what to do!
EDIT:
Both empty projects and simple "Hello World!" programs compile & run correctly. As soon as I #include <windows.h> however, the compilation problems appear.
Solved.
The problem was, the MinGW inclusions somehow ended up in the MSVC directory, making the compiler use those instead. Since they are Unix (POSIX) headers, the MSVC compiler can not compile them, and instead throws an exceptionally long list of errors. To solve this mess, I had to delete all the non-MSVC headers from the inclusion folders. The reason simple uninstall&reinstall didn't work is because MS uninstaller is file-specific and leaves all the non-original files in the directory. Visual Studio doesn't have, in fact, any Windows API header in the inclusion folder, and should be using the ones coming with Windows SDK.
So, since I've seen many people with this problem but no solutions to it, I'll leave the simplest answer here:
In order to clean up the folder from anything not needed, you have to uninstall everything first, then manually delete those folders, and finally reinstall everything. There might be more subtle solutions that would be better if you have many additional libraries installed (I had, in fact, some) and want to delete only the specific faulting headers, leaving the rest, but I don't really know how. If anybody knows of someway to do that, like maybe a tool that checks for MSVC-compatible headers and libraries, please let me know!
EDIT:
Additionally it may occur (at least in my case happened) that the VS SP1 gets also corrupted in the process, thus leading to compiler errors such as:
LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt
To solve this, refer to the solutions given in this question.
Related
When building a simple OpenCV app in Visual Studio 2015 Update 3, with OpenCV 3.2, with target x64 (there are no x86 libs in 3.2 release), I get the following errors:
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xtr1common(100): error C2737: 'std::is_same_v': 'constexpr' object must be initialized
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xtr1common(100): error C2998: 'const bool std::is_same_v': cannot be a template definition
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xtr1common(245): error C2737: 'std::is_integral_v': 'constexpr' object must be initialized
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xtr1common(245): error C2998: 'const bool std::is_integral_v': cannot be a template definition
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xtr1common(282): error C2737: 'std::is_floating_point_v': 'constexpr' object must be initialized
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xtr1common(282): error C2998: 'const bool std::is_floating_point_v': cannot be a template definition
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xtr1common(295): error C2737: 'std::is_arithmetic_v': 'constexpr' object must be initialized
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xtr1common(295): error C2998: 'const bool std::is_arithmetic_v': cannot be a template definition
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xstddef(697): error C2737: 'std::is_function_v': 'constexpr' object must be initialized
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xstddef(697): error C2998: 'const bool std::is_function_v': cannot be a template definition
Somehow I dont believe this is a problem with OpenCV, so I guess I am missing something in the build process or have something misconfigured. Any suggestions what should be changed are appreciated :)
I followed the following site http://opencv-srf.blogspot.com/2013/05/installing-configuring-opencv-with-vs.html when it comes to suggestions how to configure VS.
Adding source code, though I believe this is something related to configuration of the build, not to the source code:
#include "opencv2/opencv.hpp"
int main()
{
return 0;
}
I get the same errors when adding OpenCV 3.1 through Nuget as described in OpenCV via NuGet packages with Visual Studio 2015, how to configure? . Interesting enough it looks like similar errors where seen in completely different cases - Visual Studio 2015: C++ REST API (Casablanca) failing compilation in VS inlcudes/headers and where solved by reinstalling VS2015 from RC to full community edition. I am using VS2015 Enterprise Update 3 so I hope is not the root cause...
This problem was apparently caused by issues with VS2015. At least after I did repair of the VS2015 installation (from Program and Features in Windows, the problem is gone)
Working under Visual Studio 2010, I've developed a library to p/Invoke some stuff from a third-party native C++ dll. I haven't touched the C++ project in this solution for a while (even though I come back to the C# project every now and then) and everything was working fine. This morning I had to add a new method to the C++ project and I started getting the following error:
Error 2 error C2065: 'ENOTEMPTY' : undeclared identifier C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\system_error 40 1 xxxNativeDll
("xxxNativeDll" is my C++ wrapper to the third-party .dll)
I'm no expert in C++ but I poked around the web a bit and the closest clue I could find is in this post: https://social.msdn.microsoft.com/Forums/vstudio/en-US/0abac212-6bde-40a0-81ce-9e2b0ddaa106/conversion-error-while-converting-project-from-msvs-2008-to-msvs-2010?forum=vcgeneral
Basically someone was getting the undeclared identifier error to all the macros in system_error and in the answer, he was told these macros are defined in errno.h. Well, here are my includes in the build output, from system_error up to the error itself:
2> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\system_error
2> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\cerrno
2> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\errno.h
2> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h
2>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\system_error(40): error C2065: 'ENOTEMPTY' : undeclared identifier
Just to be sure, I highlighted ENOTEMPTY, hit F12 (go to definition) and alas! I was redirected to WinSock.h in the C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include folder. Surprisingly enough, only ENOTEMPTY redirects to this file, all other macros in system_error redirect to errno.h. I'm pretty sure it has something to do with the fact that I've installed WinDDK 7 a while back, but since I didn't need to rebuild the C++ project in this solution in a long time, there have been no errors since then.
So, long story short, VS "thinks" ENOTEMPTY from system_error is defined in WinSock.h while it should look for its definition in errno.h. Like I said, I'm no C++ pro, so how can I fix it? Please, I don't wanna add WinSock.h to my includes but I want VS to look for ENOTEMPTY in the correct file.
As pointed out in the comments, it had nothing to do with WinSock.h but rather a faulty errno.h file. I was gonna delete this question but decided to let it live as there's not enough information on these kind of problems out there.
I have a project I have been compiling using visual studio 2008 for compatibility reasons. It has been a real pain and am testing compatibility with visual studio 2015. I have custom build steps for several qt object files to run through the MOC and then compile them along with the build. Whenever I try to compile one of the moc files in 2015, I get the following error sequence:
moc_class.cpp
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\intrin.h(200): error C2062: type 'void' unexpected
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\intrin.h(200): error C2144: syntax error: 'void' should be preceded by '('
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\intrin.h(200): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\intrin.h(200): error C2365: '_InterlockedCompareExchange': redefinition; previous definition was 'function'
Any reason why this would occur? I am at a wall and can't seem to find any information on the issue. Using qt 4.5.2.
Qt4 will not work under Visual Studio 2015 unless you build that version (4.5.2) of Qt from source yourself using the Visual Studio 2015.
Another option would be to change your project so that it becomes compatible with Qt5. You can read more about how to do it here: https://wiki.qt.io/Transition_from_Qt_4.x_to_Qt5 .
Just trying the new visual 2013 Community Edition.
My old project does not compile with it.
1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\iostream
1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\sstream
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\sstream(71): error C2059: syntax error : '('
1> C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\sstream(370) : see reference to class template instantiation 'std::basic_stringbuf<_Elem,_Traits,_Alloc>' being compiled
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\sstream(71): error C2334: unexpected token(s) preceding ':'; skipping apparent function body
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\sstream(370): fatal error C1075: end of file found before the left brace '{' at 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\sstream(12)' was matched
This is related to the new platform toolset (v120) when I change to the old v100 (visual 2010) everything compiles just fine.
Any idea ?
Thanks.
I am trying to create a mixed mode (managed and unmanaged) C++ DLL with CLR option and I require the use of AFX library. So I included "afxwin.h" in a file (which uses GL/gl.h).
However I run into compile errors no matter what I do and I have tried every option in the project settings to fix them, but no use.
A. When I compile with CLR option I see this error (when it compiles the file which includes afwin.h):
1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\afx.h(24): fatal error C1189: #error : Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]
B. When I compile with _AFXDLL defined in stdafx.cpp or enabling "Use MFC in a shared DLL", to address the error in A, I see these and whole bunch of other errors in the same file:
1> _WIN32_WINNT not defined. Defaulting to _WIN32_WINNT_MAXVER (see WinSDKVer.h)
1>c:\program files (x86)\microsoft visual studio 10.0\vc\atlmfc\include\afxanimationcontroller.h(46): error C2059: syntax error : '-'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\atlmfc\include\afxanimationcontroller.h(60): error C2143: syntax error : missing ';' before '}'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\atlmfc\include\afxanimationcontroller.h(60): error C2238: unexpected token(s) preceding ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\atlmfc\include\afxanimationcontroller.h(61): error C2059: syntax error : 'public'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\atlmfc\include\afxanimationcontroller.h(65): error C2059: syntax error : ')'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\atlmfc\include\afxanimationcontroller.h(65): error C2589: '-' : illegal token on right side of '::'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\atlmfc\include\afxanimationcontroller.h(65): error C2059: syntax error : '::'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\atlmfc\include\afxanimationcontroller.h(67): error C2143: syntax error : missing ';' before '{'
Any ideas on how to fix this issue? I am using VS 2010.
Changing the MFC option afterwards to "Use MFC in a shared DLL" is not that straightforward, there are other options you may need to change.
The easiest way is to create a new dummy MFC project with the wizard and compare the project properties of the two projects.
Re CLR, what works for me is to place all managed C++ code in one or two sources and turn on /CLR only for those sources instead of the whole project.