Visual Studio 2010 win32 compiled application does not work on windows xp - c++

I'm working on a project that should run on all windows platforms. It is written in c++, using only the Windows API. When I compile it in Visual Studio 6 on Windows XP, I can run it on Windows XP. When I run it in Visual Studio 2010 and run it on Windows XP it did not work. I did install vcredist2010_x86, vcredist2010sp1_x86 and .NET versions 3.5 and 4.0 on Windows XP SP3. But it still doesn't work. I added the following preprocessor symbols to my project:
#define _WIN32_WINNT 0x0501
#define WINVER 0x0501
#define NTDDI_VERSION 0x0501
but it still doesn't work. My VS 2010 platform toolset is v100.
Question: What do I need to do to compile an application using Visual Studio 2010, that can be executed on Windows XP?

I'm using VS2010_sp1 on window_7_sp1_x64 and with 'release' mode.
I added #define previous to my include section.
And I've tested NTDDI_VERSION to 0x05010300 but problem is still alived! The error, showed by win_xp is:
"program.exe has encountered a ploblem and needs to close."
At all, I think, program needs dll or something to install on windows xp to run correctly!

Related

How to use Visual Studio 2019 to target Windows 7?

I would like to use Visual Studio 2019 to enjoy the latest C++ additions, but targeting Windows 7.
I created a Windows C++ application using the VS 2019 wizard (running on Windows 10).
A targetver.h file is created by the wizard, with the following content:
#pragma once
// // Including SDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
#include <SDKDDKVer.h>
I followed the instructions in the comment lines, and added the following lines intargetver.h (before the #include <SDKDDKVer.h> line):
// Target Windows 7 SP1
#include <WinSDKVer.h>
#define _WIN32_WINNT 0x0601
To test that, in the program's main function I invoked an API (PathCchAppend) that is not supported in Windows 7.
The program builds fine (I statically link the CRT), and runs fine in Windows 10.
The same program fails when executed in Windows 7, showing the following error message:
Now, the program should have not compiled at all, because I specified the Windows 7 target, and the aforementioned API is not available on Windows 7.
Is this a bug in the Windows SDK?
Is it possible to target Windows 7 using VS 2019 and the Windows 10 SDK, getting errors during the build process when an API or structure that is not supported in Windows 7 is used in the code, and how?
VS 2019's toolset and the latest Windows 10 SDK support targeting Windows 7 Service Pack 1.
You have already configured the Windows headers in the Windows 10 SDK properly:
#include <winsdkver.h>
#define _WIN32_WINNT 0x0601
#include <sdkddkver.h>
You can still call APIs that are not supported by Windows 7 in this mode, which is why calling PathCchAppend builds, links, and fails at runtime.
The problem you are seeing may also be related to the Universal C/C++ Runtime not being on your target machine. Install the x86 and/or x64 native version on your target test machine.
See Microsoft Docs.

Windows SDK Version setting in Visual Studio 2017

I have a c++ project that compiles well under Visual Studio 2013.
Today I installed Visual Studio 2017 Professional Edition, then there's a new setting in project settings > General called "Windows SDK Version", by default is 10.0.16299.0. Since I'm compiling windows desktop programs for targeting Windows 7 systems, I changed it to 8.1, is this correct?
Generally speaking, a Windows SDK supports its "main" version and also the previous ones, but you need to specify what Windows version your program will need. In fact, you're better off doing so or else you can inadvertently use features not available in the version you want to support.
Given an SDK, you indicate which older Windows version to target by defining the WINVER and _WIN32_WINNT macros somewhere in your project files or in the C/C++ Preprocessor project settings in Visual Studio.
For example, the following definitions target Windows 7:
#define WINVER 0x0601
#define _WIN32_WINNT 0x0601
For more information, see Using the Windows Headers and Modifying WINVER and _WIN32_WINNT
Indeed I raised this issue because my freshly installed Visual Studio could not build the VM because SDK 16299 is now indeed the default. It's mentioned here:
https://en.wikipedia.org/wiki/Microsoft_Windows_SDK.
.
Also MS does not make finding older SDK's very easy. You have to click through to another page all the way on the end of this page:
https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk
Even though I googled on "Microsoft Windows SDK 15063".
.
So all-in-all it's now a small chore for newbies to get up and running on the VM. To start, I think it should be made as easy as possible. (Complexity will come soon after that :)).
.
PS I'm not sure about Windows 7 compatibility. But the current VM SDK is also listed as being for Windows 10.

Missing shcore.dll after compiling with target Windows 7

I need to compile a VC++ VS2015 project I'm working on as a binary compatible with Windows 7. I'm using Win10 and VS2015 with v140 compiler.
As specified in this page I set the target platform to 8.1 and modified the targetver.h such as this:
#include <WinSDKVer.h>
#define WINVER 0x0601
#define _WIN32_WINNT 0x0601
#include <SDKDDKVer.h>
Obviously, it compiles correctly, but when I execute the binary on a windows 7 pc, it gives me "Missing shcore.dll", which, from what I gather is a dll available only from Windows 8.1 onwards and makes me think that I've done something wrong or there's something I'm missing.
I just had the same error on Win7 and unfortunately the DLL is not available for Windows 7. Just on Windows 8.1 and higher.
shcore.dll on Windows 7 -- does it exist?
Hope that Helps!
I got this error too while launching a WPF app on Windows 7. The good news is the error is trapped and handled internally, you can probably just ignore the exception and let the program run. Worked for me.

Build application for windows XP

I need to build application that could run on Windows XP. For this reason I found option Platform Toolset that might be set to Visual Studio 2012 - Windows XP (v110_xp) and definition #define _WIN_VER 0x0501. What does Platform Toolset does and maybe I don't need it if I define _WIN_VER 0x0501?
When you build with VS 2012 using the "v110" Platform Toolset, you are using the VS 2012 compiler and C Runtime building with the Windows 8.0 SDK. This must target Windows Vista or later because the Windows 8.0 SDK does not support building applications for Windows XP or Windows Server 2003. By default it targets Windows 8 or later, but you can set the preprocessor symbol _WIN32_WINNT to 0x0600 for Windows Vista or later, or 0x0601 for Windows 7 or later.
When you build with VS 2012 using the "v110_xp" Platform Toolset, you are using the VS 2012 compiler and C Runtime building with the Windows 7.1A SDK--the last version of the Windows SDK to support targeting Windows XP SP3 / Windows Server 2003 SP2.
Be sure to read this Visual C++ blog post and this DirectX SDK blog post for important information about using the Windows XP Platform Toolsets.
Note: With VS 20123, the "v120" Platform Toolset builds with the VS 2013 compiler, C Runtime, and Windows 8.1 SDK. It defaults to targeting Windows 8.1, but you can set the preprocessor symbol _WIN32_WINNT to 0x0600 for Windows Vista or later, 0x0601 for Windows 7 or later, or 0x0602 for Windows 8 or later. The "v120_xp" Platform Toolset builds with the VS 2013 compiler, C Runtime, and Windows 7.1A SDK.
It's just toolset. Maybe you installed only visual studio 2012, and if so you could see Visual Studio 2012 (v110) and Visual Studio 2012 - Windows XP (v110_xp).
In my case, I use several version of visual studio, so I can see Visual Studio 2008 (v90), Visual Studio 2010 (v100), etc. If I select Visual Studio 2008 (v90), the program is compiled with vs2008, even if I'm working on vs2012.
At first, VS2012 doesn't support windows xp, so its toolset also doesn't support windows xp. But after many developers ask MS to support winxp, MS adds a toolset for winxp, v110_xp. So you should use v110_xp toolset if you want to build application for windows xp.
Maybe you don't need set _WIN_VER, because vs2012 already defined it over Windows Vista at least.

How do I compile for Windows XP with Visual Studio 2012?

Ok, so I'm using Visual Studio 2012 in Windows 7 x64 for programming and compiling. My application works fine there, but when I try to execute it from a Windows XP SP3 Virtual Machine, I get "xxxx.exe is not a valid win32 application" right away.
The application is being compiled with static linking, that is, with /MT. I have set _WIN32_WINNT to 0x0501 in targetver.exe; the configuration manager is set to Win32 and the target machine in the Linker advanced options is set to MACHINEX86.
My targetver.h looks like this:
#include <winsdkver.h>
#define _WIN32_WINNT 0x0501
#define WINVER 0x0501
#define NTDDI_VERSION 0x0501
#include <SDKDDKVer.h>
I also tried compiling with /MD and installing .NET Framework, but that didn't help either.
I'm clueless, and I could really use some help as I need to have it working for Windows XP.
VC++ 2012 RTM did not support Windows XP – that support came later in 2012 in Visual Studio 2012 Update 1.
The CTP of Windows XP targeting with VC++ 2012 could be installed, but you would have to link the CRT statically in order to deploy. See this blog article for more information.
Visual Studio 2012 Update 1 added official support for running applications built with VC++ 2012 on Windows XP as well as the ability to link the CRT dynamically.
Download link
Blog article containing additional information
Two things should be done:
Configuration Properties → General page, change Platform Toolset to: Visual Studio 2012 - Windows XP (v110_xp);
Menu Linker → System. Change Subsystem to: Console/Windows.
A detailed explanation is here: http://software.intel.com/en-us/articles/linking-applications-using-visual-studio-2012-to-run-on-windows-xp
When you generate the EXE file, the version for 32-bit will be in the project folder bin\x86\Release.