KMDF driver targeted for Windows 10, not building on Windows 7(SP1) using VS 2017 - visual-studio-2017

I am creating sample(HelloWorld) KMDF driver using Visual Studio 2017 on Window 7(SP1 and 64 bit). The driver is targeted for Windows 10 and configured for x64 platform. My project does not compile and throws errors as below -
UnsignedMultiplyHigh' undefined: assuming extern returning int
__movsq' undefined: assuming extern returning int
__readgsdword' undefined: assuming extern returning int
DbgRaiseAssertionFailure' undefined: assuming extern returning int
But If i configure the project for Win32 instead of x64, it builds fine. I am not able to find the library which is missing in x64 case. I have looked at the project settings for both but can't find the differences .Can anyone suggest something?

Related

Targeting the Windows 7 OS with Visual Studio 2017 gives a ucrtbased.dll missing error

I have a client that is running a Windows 7 machine and I want to him build an .exe that he can run on his computer. However, since I am running Windows 10, I am building everything in Visual Studio 2017. The program I am making is a Winforms CLR C++ program. I put in the Windows 7 WINVER define in one of the C++ files:
#define WINVER 0x0601
The compile the project with the following properties:
I send him an .exe file but when he opens it up, it gives him a an error saying that he is missing the ucrtbased.dll. I verified that he has the correct .NET framework installed on his computer:
What could be the cause of this?
Build and send him a release copy. He will still need the appropriate windows libraries.
ucrtbase (Universal C Runtime) is the replacement for the msvc* runtime dlls.
To get the correct runtime, see https://www.microsoft.com/en-us/download/details.aspx?id=48234
and also possibly https://support.microsoft.com/en-us/help/2999226/update-for-universal-c-runtime-in-windows
if you have problems.

Visual C++ 2012 Express compiled application does not work on Windows XP?

I have the following C++ program which I am compiling with static linking (Multi-threaded (/MT)):
int main()
{
return 0;
}
I tried to run it on Windows XP (using Virtual Box), but it is telling me that it is not a valid win32 application!!
take a look at this:
http://blogs.msdn.com/b/vcblog/archive/2012/10/08/windows-xp-targeting-with-c-in-visual-studio-2012.aspx
you should install vs2012 update 1. and change your toolset to xp.

Building c++ project for Win XP in MSVC 2012

I have a console application that I need to use on Windows XP. Also i'm using MSVC 2012 as an IDE. Problem, that when i run it on Win XP (SP3) i receive error message that this application is not a valid win32 application.
UPD:
After talking care about suggestions in the comments to this question, i've updated my question.
What does use my application:
Urlmon.h/urlmon.lib
boost::program_options
c++11's regex
What i've already tryed:
Build test application like "Hello, World!". It works on target Win XP
Install Update 3 for MSVC 2012 & update 3 redist. to target machine
Build app with static linking (/MT)
Dependency walker shows 3 messages:
Missing WER.dll
Missing IESHIMS.dll
Unresolved C function "WNetRestoreConnectionA"
As far as i see nothing of listed in dependency walker should affect my app, but it still fail to load with error "not a valid win32 application".
Does anyone have ideas why>
The v110_xp toolset automatically specifies the SUBSYSTEM's MRV ("5.1" (WindowsXP)) but not the SUBSYSTEM
That was the problem. I've set SUBSYSTEM to "/SUBSYSTEM:CONSOLE" in project settings & problem with target Win XP dissapeared. Thanks everyone for comments.
As I know, MSVC 2012 toolset do not support windows XP. But you can use MSVC 2010 toolset in IDE 2012. Or use toolset v110_xp forom Visual Studio 2012 Update 1(I didn't try it).
This link may help
http://blogs.msdn.com/b/vcblog/archive/2012/10/08/windows-xp-targeting-with-c-in-visual-studio-2012.aspx?Redirected=true

MS Visual Studio 2012 Express for Windows Desktop - Targeting Windows XP

I have recently upgraded from Visual Studio Express 2010 to Visual Studio 2012 Express for Windows Desktop. I'm aware of the previous lack of compatibility targeting Windows XP, but thought this was resolved by Update 1 (which I have installed).
However, I'm still having difficulty targeting Win XP with the C++ applications I have compiled using 2012 Express. I have set the Platform Toolset to "Visual Studio 2012 - Windows XP (v110_xp)" but this makes no difference. When I try to run my compiled application on my Windows XP system (I run Windows XP via VirtualBox), I get an the error that my application "is not a valid Win32 application."
I have also tried setting the CLR Support to "No Common Language Runtime Support" and the Runtime Library to "Multi-threaded (/MT)".
Even with a very basic blank C++ project using the following code, I just can't get it to run on XP:
#define _WIN32_WINNT 0x0501
#define WINVER 0x0501
#define NTDDI_VERSION 0x0501
#include <iostream>
int main()
{
std::cout << "TEST" << std::endl;
std::cout << std::endl << std::endl << "Press ENTER to close this window.";
std::cin.get();
return 0;
}
Can anybody tell me where I'm going wrong with my compiler/project settings?
P.s. I have installed the MS VC++ 2010 and 2012 redistributable packages on my XP virtual machine. Applications that I compiled with Visual Studio Express 2010 work fine on my XP virtual machine.
Check your project's "Configuration Properties -> Linker -> System -> Subsystem" properties.
If blank, fill it with (/SUBSYSTEM:CONSOLE) or (/SUBSYSTEM:WINDOWS).
This works:
Configuration Properties -> Linker -> System -> Subsystem =
/SUBSYSTEM:WINDOWS
Configuration Properties -> General -> Platform Tool Set ->
SubsystemVisual Studio 2012 - Windows XP (v110_xp)
Using Visual Studio 2012 Express Update 3.
Use GNU GCC tool chain, bro, that redistrebuted with mingw. MSVS actualy just minimize dependencies, but some of them still stay in exe. Just compiling in gcc suports full static linking, with small exe size and stable compatibility.
The message is indicating that your build isn't producing a 32 bit application--if it were a version dependent API, for example, you'd see another error indicating that the symbol can't be found. Since you have indicated that you are using the correct target platform in the configuration manager, check your property explorer to make sure you don't have conflicting arguments or defaults. If you see link with the option /MACHINE:X64, then you've found the problem.
If that doesn't work, I suppose you could try running Sysinternals process explorer to see which cl/link are actually being launched with which arguments. Hope that helps.

How do I compile for windows XP under windows 7 / visual studio 2008

I'm running Windows 7 and Visual Studio 2008 Pro and trying to get my application to work on Windows XP SP3.
It's a really minimal command line program so should have any ridiculous dependencies:
// XPBuild.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
printf("Hello world");
getchar();
return 0;
}
I read somewhere that defining several constants such as WINVER should allow me to compile for other platforms. I've tried the added the following to my /D compiler options:
;WINVER=0x0501;_WIN32_WINNT 0x0501;NTDDI_VERSION=NTDDI_WINXP
But that made no difference. When I run it on my Windows XP machine (actually running in a virtualbox) I get the following error:
This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem.
So what have I missed? Is there something else required to run MSVC compiled programs or a different compiler option or something else?
What you have missed is most likely that VC++ programs require a runtime to be installed (unless you link statically, which is not the default) - the error message you show is exactly the one you get if they're not in order.
Try installing the Microsoft Visual C++ 2008 SP1 Redistributable Pack on the XP machine - you will most likely see that your program works with no changes whatsoever.
Michael's answer explains why it doesn't work for you, and what you should do about it. With respect to WINVER - they don't change anything about your binary in a sense that it would suddenly start working on XP. What they do is disable function and type declarations in Windows headers files that are not supported on the OS version specified by WINVER. This ensures that you do not accidentally call e.g. some Vista-only function. However, you don't strictly need it - if your code does not rely on any Vista/7-only functionality, you can compile without redefining WINVER, and it'll still work fine on XP.
Just Set the compiler to use static linking in the project settings (Project -> Properties -> Config Properties -> C/C++ -> Code Generation -> Change "Runtime Library" to /MT or /MTd instead of the default /MD or /MDd)