I have a C++ project that references many other projects/libraries. This is for an application that was created many years ago. About every once a year it is updated and a new version is done. I've used Visual Studio 6 to update and build new versions of this app for years now without any problems.
I am trying to switch to Visual Studio 10 (and now VS2013). Initially I ran into several warnings and errors which were due to compatibility issues between the VS versions. I was able to take care of most. However, I'm still somewhat confused by the following error:
error C1189: #error : MFC does not support WINVER less than 0x0501. Please change the definition of WINVER in your project properties or precompiled header. C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\afxv_w32.h
The error occurs in a few of the referenced project libraries. I checked the project libraries in question and I cant find any reference to WINVER.
I have searched the internet for info on this and found some topics but nothing that is specific to my problem. Can someone shed some light as to what might be happening here?
Thanks in advance.
LA
All MFC apps define the WINVER macro value somewhere if you didn't define it yourself. I assume MS has removed the definition by default on its own header files and is now making mandatory that you explicitly define it.
So, to solve your problem, either put the #define in your 'preprocessor' compiler options, or at the top of your precompiled header (ie stdafx.h).
Note 0x501 is Windows XP support. 0x600 is Vista, 0x601 is Windows 7 — and how sad am I for remembering that!
I got the same error, on Windows 7 with Visual Studio 2013.
In my case my project had a source file with name stdafx.h, inside that file there was
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0500
#endif
I changed it to
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x601
#endif
and the error disappeared.
By default WINVER is defined as 0x0500 in preprocessor. To overcome from this error, remove defined win version "WINVER=0x0500" from
Configuration Properties => c/c++ => Preprocessor tab and rebuild.
Or you can provide higher WIN VERSION as #define _WIN32_WINNT 0x601 in your code wherever you getting error.
Related
My C++/MFC code compiles fine with VS 2013 but when I have compiled with VS 2015 I get this error:
C:\VS\VC\atlmfc\include\atlwinverapi.h(710):
error C3861: 'LCMapStringEx': identifier not found
I don't use LCMapString anywhere in my code, so I don't know where this come from?
I had the same problem. For me the cause was this: Part of the project had _WIN32_WINNT set in such a way that XP was supported, other files didn't have this define. So the MFC headers were included with different values for the supported platform leading to this strange error.
The definition is guarded for the minimum target windows version.
This guard uses one of your definitions or NTDDI_VERSION (which is created from the other definition within (sdkddkver.h).
Correcting the version details of _WIN32_WINNT, WINVER solved the issue.
Go to:
Properties->Configuration properties->C/C++->Preprocessor->Preprocessor
Definitions and check what macros are defined.
changing them to
NTDDI_VERSION= 0x06030000
WINVER=0x0A00
_WIN32_WINNT=0x0A00
solved my problem.
Here 0A00 is for windows10.Refer below link
https://msdn.microsoft.com/en-us/library/windows/desktop/aa383745(v=vs.85).aspx
In StdAfx.h define the following macros:
//For Windows 10
NTDDI_VERSION 0x0A000000
#define WINVER 0x0A00
#define _WIN32_IE 0x0A00
Also refer below MSDN links for WINVER & NTDDI_VERSION according to your environment.
https://learn.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt?view=vs-2019
https://learn.microsoft.com/en-us/windows/win32/winprog/using-the-windows-headers
I Solved the problem. I had to manually delete all the obj files generated by the previous compiler, as the clean and rebuild option in VS 2015 seems that did not remove them correctly.
Correcting the version details of _WIN32_WINNT, _WIN32_WINNT solved the issue.
you can see the similar thread here.
Compile Errors upgrading ATL project from vs2010 to vs2013
(WINVER or _WIN32_WINNT)
I faced similar issue when I migrated project from Visual Studio 2005 to Visual Studio 2015.
Open the Vcxproj in notepad or any of your favorite editors and then search for <PreprocessorDefinitions> tag in my case I removed the WINVER=0x0501, when I removed it started working.
I am running a DirectX 11 application on windows 7 and visual studio community 2015 RC. I'm still using functions from the DX SDK. It worked fine on VS2013 but when I switched over I get only the following error:
Error LNK2019 unresolved external symbol __vsnprintf referenced in function "long __stdcall StringVPrintfWorkerA(char *,unsigned int,unsigned int *,char const *,char *)" (?StringVPrintfWorkerA##YGJPADIPAIPBD0#Z) Ancora D:\Moody\Moody\Projects\Projects\Ancora\Ancora\dxerr.lib(dxerra.obj) 1
I only use the DXGetErrorDescriptionA function from the dxerr library and when I comment it out, the program compiles fine. I have no idea what's wrong but it can't be from the DX SDK or otherwise the other functions would fail right?
I experienced the same problem using DXGetErrorMessage() with Dx9 and found out that MS have provided an additional library to include in the Additional Dependencies properties page to address this problem. The library name is: legacy_stdio_definitions.lib
Adding this resolved the issue for me.
just add
#pragma comment(lib, "legacy_stdio_definitions.lib")
https://msdn.microsoft.com/en-us/library/bb531344.aspx
Instead of hacking dxerr.lib manually, you could add
#include <Windows.h>
#include <stdio.h>
int (WINAPIV * __vsnprintf)(char *, size_t, const char*, va_list) = _vsnprintf;
somewhere in your code
The legacy DirectX SDK is quite old, and dxerr.lib in the DXSDK is not compatible with VS 2015's C Runtime as you have encountered.
In general static libraries with code in them don't mix well from different versions of the compiler. Most of the .libs in the legacy DirectX SDK work with VS 2015 because they are import libraries for dlls or all data libraries and therefore contain no code at all. The DXSDK has not been updated since VS 2010.
Aside: The VS team has made a heroic effort to keep the Visual C/C++ Runtime link compatible between VS 2015 Update 3, VS 2017, and VS 2019 per Microsoft Docs. This is not the normal pattern.
Be sure to read the instructions on Microsoft Docs on the proper way to mix the legacy DirectX SDK with the Windows 8.x SDK used by VS 2015. You are presumably using something else from the legacy DirectX SDK in this project besides dxerr.
I have implemented a version of DXERR that you can build from source in your project to remove this dependency of the legacy DirectX SDK. See this post for details. That said, I purposely only supported Unicode (the W version). You can work out how to make the ANSI (the A version) easily enough, but it would be best if updated your app to use Unicode.
See Where is the DirectX SDK (2021 Edition)? and DXUT for Direct3D 11.
UPDATE: As noted in another answer linking with legacy_stdio_definitions.lib should make the old legacy DirectX SDK version of dxerr.lib link again with VS 2015/2017. That said, you should work on removing dependencies on the legacy DirectX SDK as much as possible and DXERR is easily replaced by your own module. See Living without D3DX.
The DirectX libraries you are using are compiled with an older version of Visual Studio than you are using. Microsoft sometimes makes changes to their C runtime, creating incompatibilities between libraries compiled with different versions. __vsnprintf was an internal symbol in older versions of their C runtime, it does not exist in the 2015 RC version.
Unfortunately, dxerr.lib (along with d3dx11.lib) have been deprecated. You have two options - you can switch back to VS2013 or you can stop using functionality from dxerr.lib. The latter is probably better, because you can duplicate its functionality by using FormatMessage now (more info in the linked article).
HACKY but you could patch dxerr.lib.
Replace __vsnprintf with _vsnprintf (with a null at the end to account for the removed underscore at the beginning)
You can change the Platform Toolset from Visual Studio 2015 to Visual Studio 2013 and then it compiles.
The Platform Toolset is found on the General tab of the Project Properties.
I am trying to compile the code originally written in Visual studio 6 to VS 10.
I read in one of the MSDN article that 'atlmfc' has been removed from VS10. what is the alternative for atlmfc in VS10 ?
error is pointing to atlchecked.h file.
error C2664: 'AfxCrtErrorCheck' : cannot convert parameter 1 from 'char *' to 'errno_t'
1> There is no context in which this conversion is possible
.
.
program files (x86)\microsoft visual studio 10.0\vc\atlmfc\include\atlcomcli.h(2235): error C2065: 'cVal' : undeclared identifier
These errors are in all the header files like atlcomcli.h, oaidl.h.
part 1) I guess that whatever is included in #ifdef has not been recognized in VS10, I might need to give correct path or include relevant header file. Surprisingly no solution on the net so far. If I compare with other solution it doesnt seem to be a problem since path is correct. I am picking all the atlmfc files from visual studio 10 version.
part 2) as Scott said code change is required but here the problem it points to is
#ifdef _AFX
#define ATLMFC_CRT_ERRORCHECK(expr) AFX_CRT_ERRORCHECK(expr)
#else
#define ATLMFC_CRT_ERRORCHECK(expr) ATL_CRT_ERRORCHECK(expr)
#endif
One of the article on the net says - http://msdn.microsoft.com/en-us/library/bb531344.aspx
"#ifdefs in the MFC header files are removed." What does that mean ? if that is removed any alternative for that in Visual studio 10 ?
Also can i directly convert VS6 code to VS10 or should i convert it to VS8 first and then migrate it to VS10 ? Pls help.
'atlmfc' is a folder name in the VC directory. It has not been removed in the versions of VC that cost money but it is removed in the "express" version, which is free. You must have a paid-for version of VC to use the MFC and ATL libraries.
I think VS10 will open and convert your VS6 project, although the result will still require you to make code changes.
Well, direct conversion from visual studio 6 to VS10 is not possible. Why will microsoft allow that ? :)
we have to go through VS5 and then VS10.
also the conversion is gonna be extraordinarily difficult with lot of code changes.
http://www.devx.com/cplus/10MinuteSolution/28908
I'm using Visual Micro to write code for an Arduino (Nano in this case) in Visual Studio 2012. I have a compile error in the generated .vsarduino.h file, an empty #define is being generated and I'm not sure where it is coming from:
.vsarduino.h
#ifndef _VSARDUINO_H_
#define _VSARDUINO_H_
//Board = Arduino Nano w/ ATmega328
#define __AVR_ATmega328P__
#define
#define _VMDEBUG 1
Sorry we missed this question. Hopefully it was answered in the Visual Micro forum.
The vsarduino.h is not included in the compile and is only used for Visual Studio intellisense.
Only real Arduino source is compiled by Visual Micro which means the sketch remains compatible with the Arduino IDE
Thanks
When I type
#include <QObject>
it complains that it couldn't find file.
but if I type
#include <QtCore\QObject>
It works properly.
I moved VS2005 to VS2008, this was not the case in VS2005, and it started with VS2008. Why am I getting this error?
Actually it's not so big problem. You need to check you include directories and add (path_to_qt_headers)/QtCore, (path_to_qt_headers)/QtGui and directories for other modules you are using. According to your problem description you have added only (path_to_qt_headers) itself.
If Qt set up correctly both #include <QObject> and #include <QtCore/QObject> should work but second one works in more cases. I remember I saw some notice somewhere in the Qt documentation that it might be better to using second include style. At the same time this long include version is recommended in the KDE coding guidelines.
For myself I preffere to follow #include <QtModule/QClass> include convention
Maybe installing the Visual Studio addin for Qt would solve the problem (besides providing advanced debug and Qt project management tools).