"is not a valid win32 application" on windows xp - c++

Phenomenon:
Build a c++ program using visual studio express 2015 on windows 7 platform. Copy the executable file to xp system, cannot run with the error"not a valid win32 application"
Have tried two things
go to "configuration properties" and set the "Platform Toolset" to "visual studio 2015 - windows xp(v140_xp)"
go to "configuration Manager" and set the Platform to "Win32" (instead of x64) after these steps, still gives me same problem.
anyone knows what is the root cause of this problem? thank you!

The main problem is the Windows SDK that you are using.
Most recent Windows SDK have a compatibility list that will go far back to Windows 7.
Here are two useful links:
https://blogs.msdn.microsoft.com/vcblog/2015/07/24/setup-changes-in-visual-studio-2015-affecting-c-developers/
Targetting Windows xp from visual studio 2015 enterprise update 1

Related

Error MSB8036: The windows SDK version 10.0.17763.0 was not found

OS: Windows 10 64bit
Platform: Visual Studio 2019
I'm compiling C++ DLL project.
Although I installed "Windows 10 SDK (10.0.17763)" and "Visual Studio SDK", the visual studio can"t see the SDK.
I try to "Retarget Solution" but there is no list of Windows SDKs.
The WindowsSdkDir, WindowsSdkDir_10 environment variables are empty.
How do I get the Visual Studio 2019 to detect the installation of the Windows SDK and associate it to my project
Usually you can select a specific Windows SDK (exact version) or "newest" SDK in your project properties (right click, properties).
I think your project uses some specific Windows SDK Version which is not installed on your machine. To make your project Windows SDK-version independent you should go to the properties page and select "Windows 10 SDK (newest)" - or similar

Visual Studio 2015: building with the Windows XP toolset selected still results in "not a valid win32 application" error on XP

Visual Studio 2015 supports building C++ programs for Windows XP. According to the article Configuring C++11 Programs for Windows XP, enabling this support is simply a matter of selecting the appropriate platform toolset in the project properties.
This does not work in my case. A simple "hello world" program written in C++ and compiled in Visual Studio Community 2015 (version 14.0.24720.00 Update 1) with the platform toolset set to Visual Studio 2015 - Windows XP (v140_xp) and the platform set to x86/Win32 generates the generic "[name of executable] is not a valid Win32 application" error when run on a Windows XP computer.
Any suggestions would be appreciated. I've found a number of questions about similar issues (like these three), but nothing helpful yet.

Visual Studio 2015 RC Community Edition Target Platform set to Windows 10 TP on Windows 8.1

I just freshly installed Windows 8.1 and Visual Studio 2015 RC Community Edition.
The compilation of an existing c++ project failed, not finding <windows.h> for include. In order to fix that I installed Windows 8.1 SDK with no luck.
Looking into it my Project Settings for the "Win32" configuration says:
Why does VS2015 display Windows 10 as default target platform and why can't I change the value to Windows 8.1?
The installation of
Microsoft Visual Studio 2015 Tools for Windows 10 (Technical Preview)
and
Windows Software Development Kit - Windows 10.0.10069
seems to be done by default during Visual Studio 2015 RC setup.
The optional selection of Windows 8.1 and Windows Phone 8.0/8.1 Tools does not seem to install the respective Platform Toolsets properly alongside of the Windows X versions in order to be able to change that on the respective project settings page.
Uninstalling the above mentioned Tool- and SDK-Kits for Windows 10 made
Target Platform Windows
available in the Project Settings and I can choose Version 8.1 now.
Now <windows.h> is found again.
I had the same problem.
I changed the platform toolset to v140_xp, and closed VS2015. After opening VS2015 asked to install Windows XP C++ libraries, 225MB. After these steps my project was compiled successfully. Hope this helps you.

visual studio 2008 C++ no x64 platform

I installed Visual Studio 2008 on my Windows 7 x64 laptop together with installation of Service Pack 1.
Now I want to add x64 platform to my C++ solution. But there is no x64 platform available in the configuration manager for my project. I'm sure I manually selected x64 support during the Visual Studio installation and it was installed.
What is wrong with my setup?
If I recall, VS 2008 Pro doesn't install the 64-bit compiler and tools by default. You have to explicitly select them during the installation.
Control Panel -> Uninstall Programs.
Select Visual Studio and click Uninstall/Change.
Wait. Wait some more. Click Next.
Choose Add or Remove Features.
Expand MSVC 2008 -> Language Tools -> Visual C++.
Select X64 Compilers and Tools.
You'll probably need your original installation media.
Once the 64-bit compiler and tools are installed, you should be able to add a 64-bit configuration to your solution.
See "Use Visual Studio to build 64-bit application" for all you need to build x64 apps with Visual Studio 2008.
Visual Studio 2008 only comes with x64 compiler with the Professional editions and higher. You can download the free Windows SDK from MSDN to get the x64 compiler.
If your projects don't have the x64 configuration, just add that configuration via the configuration manager. I don't remember if 2008 created the x64 configuration by default but I suspect not.
I also seem to remember that you can just add the x64 configuration to the solution and it will prompt on whether or not to add it to all of the contained projects but my memory is rusty on that one.
Regardless, once you've got the configurations added, you'll need to modify anything you'd modified before in project settings. Output paths, library dependencies, etc. The New Configuration "Wizard" is pretty dumb.

How to compile a 64-bit application using Visual C++ 2010 Express?

Is there a simple way to compile a 64 bit app with the 32-bit edition of Visual C++ 2010 Express? What configurations, if any, are necessary?
Here are step by step instructions:
Download and install the Windows Software Development Kit version 7.1. Visual C++ 2010 Express does not include a 64 bit compiler, but the SDK does. A link to the SDK: http://msdn.microsoft.com/en-us/windowsserver/bb980924.aspx
Change your project configuration. Go to Properties of your project. On the top of the dialog box there will be a "Configuration" drop-down menu. Make sure that selects "All Configurations." There will also be a "Platform" drop-down that will read "Win32." Finally on the right there is a "Configuration Manager" button - press it. In the dialog that comes up, find your project, hit the Platform drop-down, select New, then select x64. Now change the "Active solution platform" drop-down menu to "x64." When you return to the Properties dialog box, the "Platform" drop-down should now read "x64."
Finally, change your toolset. In the Properties menu of your project, under Configuration Properties | General, change Platform Toolset from "v100" to "Windows7.1SDK".
These steps have worked for me, anyway. Some more details on step 2 can be found in a reference from Microsoft that a previous poster mentioned: http://msdn.microsoft.com/en-us/library/9yb4317s.aspx.
64-bit tools are not available on
Visual C++ Express by default. To
enable 64-bit tools on Visual C++
Express, install the Windows Software
Development Kit (SDK) in addition to
Visual C++ Express. Otherwise, an
error occurs when you attempt to
configure a project to target a 64-bit
platform using Visual C++ Express.
How to: Configure Visual C++ Projects to Target 64-Bit Platforms
Ref:
http://msdn.microsoft.com/en-us/library/9yb4317s.aspx
And make sure you download the Windows7.1 SDK, not just the Windows 7 one. That caused me a lot of head pounding.
I found an important step to add to this - after you've installed the SDK, go to your project properties and change Configuration Properties->General->Platform Toolset from v100 or whatever it is to Windows7.1SDK. This changes $(WindowsSdkDir) to the proper place and seemed to solve some other difficulties I was encountering as well.
Note that Visual C++ compilers are removed when you upgrade Visual Studio 2010 Professional or Visual Studio 2010 Express to Visual Studio 2010 SP1 if Windows SDK v7.1 is installed.
For instructions on resolving this, see KB2519277 on the Microsoft Support site.
Download the Windows SDK and then go to View->Properties->Configuration Manager->Active Solution Platform->New->x64.
Programming in a 64-bit environment is quite different than 32-bit environment.
Code generated has totally different assembly constitution in 32 & 64-bit code, even the protocols of communicating with functions change. So you can't generate 64-bit code using 32-bit compiler.
You might want to see an article on Microsoft's web site about targeting a 64-bit target but using a 32-bit development machine.
As what Jakob said: windows sdk 7.1 cannot be installed if MS VC++ x64 and x86 runtimes and redisrtibutables of version 10.0.40219 are present. after removing them win sdk install is okay, VS C++ SP1 can be installed fine again.
Kind regards