Visual studio 2013 project with v120_xp toolset has MIDL 2072 error - c++

I have recently moved to visual studio 2013 and upgrade all my c++ projects to use 8.1 of the windows SDK and the v120_xp toolset. A large majority of the projects are compiling and working fine i do however have two projects that refuse to build with several errors similar to the following error:
error MIDL2072: inapplicable attribute : [annotation] [ Field 'pDescription' of Struct 'D3D10_MESSAGE' ( Type 'D3D10_MESSAGE' ) ]
All the errors refer to the d3d10sdklayers.idl file. This occurs when the projects idl file is compiled as part of the project if i compile the file alone its fine.
Any help or suggestions are appreciated, thanks.

and upgrade all my c++ projects to use 8.1 of the windows SDK
That's where that went wrong. When you use the v120_xp toolset then you use an old version of the Windows SDK. Version 7.1, the last one that's still compatible with XP. With #include files that are different, and build tools like midl.exe that are older.
You cannot use this old version of midl.exe on the 8.1 version of d3d10sdklayers.idl. It contains attributes that it doesn't know how to process. It chokes on the _Field_size_(DescriptionByteLength) that's present in that file. Only the 8.x version of midl.exe can deal with it.
You are kinda lucky to run into this problem, there are a lot more hidden traps in the 8.1 SDK headers that will make your program fail to work properly on XP. Pretty hard to diagnose too. If you require XP compatibility then you must use the 7.1 headers. You'll have to fix to the damage you did to the projects, presumably the VC++ Directories settings. Or give up on supporting XP, the time has come.

Related

How can I reference CChannel.h in Visual Studio 2012?

I'm trying to create a C++ DLL to register with Terminal Services to provide virtual channel functionality. Unfortunately the header CChannel.h cannot be found.
I'm using Visual Studio 2012, which is targeting Windows SDK 8.0. Sure enough, the required header is missing. However, it is present in the 8.1 \include\um directory
Reinstalling the SDK has not changed matters. Manually referencing the 8.1 include directories causes all sorts of issues.
Is there a simple way to get these headers installed under 8.0?
This seems to be a problem others have encountered before, without a direct resolution.
Oddly, cchannel.h is only missing from Windows SDK 8. It is present in SDK 7 and SDK 8.1.
I resolved the problem by using the v110_xp platform toolset. This targets a version of the Windows 7 SDK, but uses the latest compiler (as of VS2012).
VS2012 Update 4 must be installed to access this toolset. More details can be found here.

Visual Studio 2013 msvcr120 to msvcr100

Is it possible to change the restrib file to msvcr100 so other computers can run the program without having problems with the .dll file? If so how do i get that?
I do compile the program and other people can't use it because of the missing msvcr120.dll file. So it would be great if i could change that somehow.
Is it possible to install the Plattformtoolset without a older Visualstudio version?
You have a few choices:
Install VS2010 on the machine, and set the Platform Toolset option to v100.
Install the Windows SDK v7.0A from here, which SHOULD / CAN add a new option to your Platform Toolset menu in VS2013. Getting this to work can be quite fiddly though. (It's rarely worked for me right out of the box). Note if you use MFC in your application, this option isn't any good for you - MFC libraries are not included with this SDK.
Get your users to install the Microsoft VS 2013 C++ Redistributable Package from here, and carry on regardless.
Statically link to the VS2013 runtimes, instead of using dynamic linking to the runtime DLLs. You can set this in the IDE through project settings under C/C++ > Code Generation > RunTime Library > Multi-threaded (/MT) or (/MTd). All the needed code will be compiled into your app, which will make the files bigger, but will avoid the issues you mention.
In Project > Properties > General, there is a setting called Platform toolset. You can use that to change the version of the build toolchain used.
One thing to consider in regards to changing the platform toolset: it changes the compiler, so C++ features newer than Visual Studio 2010 will not compile. It also requires the other version to be installed.
The best way to handle this would be to give them the Visual C++ Redistributable for Visual Studio 2013.
You could either have them do it themselves, or make an installer.

VS 2012 - XP Issues

I installed VS 2012 Professional and the XP update as well. I built my project with v110_xp as the platform toolset on VS 2012. My project's .msi package is installing fine on Win 7 but failing on Win XP SP3. The error reported on XP SP3 is -
"The procedure entry point FlushProcessWriteBuffers could not be
located in the dynamic link library Kernel32.dll".
While the same project built from VS 2005 is installing fine on XP SP3. I am not sure what is going on VS 2012. _WIN32_WINNT is set to 0x0501. Can some one please guide as how to resolve the problem ?
Any help is highly appreciated,
Mahesh.
Yes, the C Runtime has a dependency on FlushProcessWriteBuffers(). The updated version of msvcrt110.dll and libcmtl.lib, the ones you got along with the update, no longer directly link to the function, they use GetProcAddress() to find it and limp along if it is missng. So you should never get this error.
So very high odds that you deployed the wrong version of msvcrt110.dll, an old one instead of the updated one. You can find it back in c:\windows\system32, look at the properties. Mine is version 11.00.51106.1, dated 11/5/2012. A separate installer is available for it here.
The VS2012 runtime that you are installing uses functions that are not present available in XP. See this MS article: Targeting Windows XP with C++ in Visual Studio 2012 which explains more and provides some workarounds.
Update 1 for VS2012 resolve the problem.
But Update 1 isn’t just about new Windows platforms. It also enables you to target Windows XP with native C++ applications in Visual Studio 2012.
If you are building with update 1 and still encountering problems then I suspect that you are installing an out of date runtime. You need to deploy the runtime delivered with update 1.
You can solve this by including the VC11 merge modules from your development machine(program files\common files\merge modules) in your installer. It's easier than having to run the redist exe in your installer.
If you use WIX: merge module addition
I've tested on server 03, xp64 and xp32.

How to compile VC++ 2010 projects using Visual Studio 2012 and Windows SDK 7.1

I have a lot of projects done with VS2010 in C++. Now we have switched to VS2012 but we want to continue building the projects with the VS2010 runtime (we need to support Windows XP).
To our understanding this could be possible using Windows SDK 7.1 as the VC compiler is there so we installed it. VS2012 recognized the SDK and now we have a Platform Toolset named Windows7.1SDK.
The problem comes when building the projects as some projects are returning a:
error MSB6006: "CL.exe" exited with code -1073741515.
Also, projects depending on the MFCs are failing too. MFCs aren't available with Windows SDK? Does this mean that we need to buy VS2010 licenses to install them on machines with VS2012 just to build using the VS2010 compiler?
Thanks in advance.
Looks like it's not possible at all, mainly because nothing but VS2010 is deploying the MFC libraries and we have a lot of projects using them.
We'll have to buy licenses for VS2010 and VS2012 :S
I would try raise the msbuild verbosity level (it is in Tools->Options->Project and Solution-> MSBuild) and check out the command of CL.exe with full parameters. Then check if it is different from what you saw on VS2010.
In fall Microsoft will release an update to support windows xp in visual studio 2012, you can read more in this MSDN blog:
http://blogs.msdn.com/b/vcblog/archive/2012/06/15/10320645.aspx

Linking against older version of runtime with newer version of MSVC?

I own VS 2008 Pro, and would like to do compatibility testing with VS 2005's runtime MSVCRT80, but I do not want to buy it just for that. Is there a way to link against MSVCRT80 without getting VS 2005?
Thanks
Official support for native multi-targeting didn't appear until Visual Studio 2010, which allows you to select either v100 or v90 as your "Platform Toolset". There is no such feature in Visual Studio 2008.
There is a discussion here on how one can achieve the same effect in Visual Studio 2008, but it appears you need to have VS 2005 installed on your computer as well in order for this to work. It isn't going to work if you just have the runtime libraries installed because you need the proper version of the compiler and linker, which you'll only have if you install VS 2005.
On that note, I'm not really sure what you mean by "compatibility testing". If you compile your app against v90 in VS 2008, it's not going to work with the older versions of the runtime. You have to compile and link against the version you want your app to use.
Finally, consider whether it's really relevant or not. Since you must include MSVCRT with your application anyway, what's the advantage of trying to link against an older version of the runtime? Just include v90 and be done with it.
Links to a still-working (as of 11 Jan 2011) Microsoft download for Visual C++ Express 2005 can be found here:
http://apdubey.blogspot.com/2009/04/microsoft-visual-studio-2005-express.html
This should let you compile against the VS2005 runtime without having to buy anything.
(in case the blogspot article goes away, the link for the .iso is http://go.microsoft.com/fwlink/?linkid=57034).