how to forece mfc to use Redistributable 2013 or below - c++

I create an Activex by vs2015 and '/clr' option. when i run it on other pc's, it need Redistributable 2015.
But Redistributable 2015 not installed on win8.1 and win2012 server. but Redistributable 2013 installed on them.
How can i force mfc to use Redistributable 2013? (or better solution)
i checked this but not helpful.
and changing Platform Toolset to Visual Studio 2015 - Windows XP (v140_xp), generate some errors in a hello-word project
i use Activex because i need events
it use 'clr' option, because i use a managed dll in this activex
Redistributable 2015 log Error 0x80240017: Failed to execute MSU package apparently for Windows8.1-KB2999226-x64.msu
Windows8.1-KB2999226-x64.msu standalone installer say The update is not applicable to your computer.
installing a Net4.6 suggested, But this installer blocked by The update corresponding to KB2919355 needs to be installed before you can install this product on Windows 8.1 or Windows Server 2012 R2 and this update is 690.8 MB, and that MB blocked me.

You can not switch Visual Studio to use older toolset. You have to either - install older version of MSVC, or link your program statically, removing need in the redistributable altogether. To staticaly link your project open its Release properties, navigate to the C++/Code generation node and select Multithreaded instead of Multithreaded Dll for the Runtime option.

Related

How to compile C++ app for Windows XP in MSVS?

As I read this article, it is enough to download most recent MSVS 2022 and then install toolset C++ Windows XP Support for VS 2017 (v141) tools [Deprecated].
After that in Visual Studio inside project properties I set this toolset. According to linked article it is enough to compile C++ app with XP support.
But after my .exe file is created if I run it on XP 64-bit SP2 then it shows error that CompareStringEx function is not found in KERNEL32.DLL.
Hence it appears that it is not enough to use this toolset. Something else is needed.
In some other places I see that one needs also to add define /D_USING_V110_SDK71_ when compiling and option /SUBSYSTEM:CONSOLE,5.01 when linking. In my project properties I also tried to add this two options, but still CompareStringEx is inside import table of final application.
As suggested by #BenVoigt, I did defines /DWINVER=0x0502 /D_WIN32_WINNT=0x0502. Also set C++ standard to /std:c++14 (I would set C++11 but this MSVS version allows to set only C++14 at minimum). Still some non-XP symbols remain in final EXE like InitializeSRWLock that is possibly used by C++11's std::mutex in my code.
Does anyone know everything what is needed in order to compile fully XP-compatible application?
Update. I managed to build working XP application by doing things above plus setting C++ CRT runtime to Multi Threaded DLL, i.e. using dynamic DLL linkage of CRT. Also as suggested by #ChuckWalbourn (down x86 or x64 redists), I downloaded older version of msvcp140.dll.
But it is very important for my project to have statically linked runtime (C++ CRT), i.e. use Multi Threaded value for Runtime field in project properties. Only if it is REALLY not possible only then I will use DLL CRT. Until then solution about how to link CRT statically are welcome, of course to produce XP-compatible EXE.
TL;DR For Window XP VC++ REDIST support, install https://aka.ms/vs/15/release/VC_redist.x86.exe on your Windows XP system
-or-
if you are doing "side-by-side application local deployment", then use the DLLs from C:\Program Files\Microsoft Visual Studio\2022\<edition>\VC\Redist\MSVC\14.16.27012\x86\Microsoft.VC141.CRT.
If you want the latest bug fixes to the CRT, you can also download the REDIST for VS 2019 (16.7) per the link on Microsoft Docs.
For Windows XP targeting, you use the v141_xp Platform Toolset installed by Visual Studio (VS 2017, VS 2019, or VS 2022) which is the latest VS 2017 (v141) C++ compiler using an included Windows 7.1A SDK.
Make sure you have installed (for VS 2022) the following individual components since you are using MFC:
Microsoft.VisualStudio.Component.WinXP: C++ Windows XP Support for VS 2017 (v141) tools [Deprecated]
Microsoft.VisualStudio.Component.VC.v141.x86.x64: MSVC v141 - VS 2017 C++ x64/x86 build tools (v14.16)
Microsoft.VisualStudio.Component.VC.v141.MFC: C++ MFC for v141 build tools (x86 & x64)
If you are doing DirectX development, be sure to read this blog post as well for various implications of using the Windows 7.1A SDK.
For deployment to Windows XP, you can install the latest VS 2017 Visual C++ REDIST or use VS 2019 Visual C++ up to VS 2019 (16.7). After that the REDIST DLLs themselves are not compatible with Windows XP.
On your development system with VS 2022 installed, you are going to have a newer set of Visual C++ REDIST files which are binary compatible with your v141_xp Platform Toolset built EXE, but those VC++ REDIST DLLs are not compatible with Windows XP.
IOW: If you look at a dumpbin /imports of the 14.30 (v143 version), 14.29 (v142 latest version), and/or 14.16 (v141 latest version ) copies of msvcp140.dll you will see different imports. The msvcp140.dll sitting in your C:\windows\SysWOW64 folder is going to be the 14.30 version.

How can I set up Visual Studio 2017 to develop drivers?

According to this forum, https://answers.microsoft.com/en-us/windows/forum/windows_10-hardware-winpc/windows-wdk-on-visual-studio-2017-community/fdbd2b44-e57a-4849-903d-04001205a764
Windows Driver Kit is not currently supported by visual studio 2017.
I tried installing the Windows Driver Kit, but the test driver projects, such as this one, fail to build
https://github.com/Microsoft/Windows-driver-samples/tree/master/serial/VirtualSerial
I get this error when building:
Error MSB8020 The build tools for WindowsUserModeDriver10.0 (Platform Toolset = 'WindowsUserModeDriver10.0') cannot be found. To build using the WindowsUserModeDriver10.0 build tools, please install WindowsUserModeDriver10.0 build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution".
I already tried retargeting the Solution to the two options I have: 10.0.17134.0 and 8.1, but the same error keeps coming up.
What do I need to do to build this sample driver? Do I need to install VS2015? VS2017 community edition? Why isn't this WDK supported by the Visual Studio 2017 professional version?
Thanks,
Visual Studio 2017 definitely supports kernel-mode device driver development; there's no doubt about that because I've been using VS17 for it for many, many months.
Use the latest version of Windows Driver Kit (WDK) which can be downloaded and installed from MSDN: https://learn.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk
Furthermore, you can always use the Enterprise WDK and then you can simply build using that if you wanted to from command-line. (Also can be found on page linked-to above)
Download the correct WDK installer for your edition of Visual Studio 2017:
WDK for Windows 10, version 1809 for Visual Studio Community 2017
WDK for Windows 10, version 1803 for Visual Studio Professional 2017
WDK for Windows 10, version 1709 for Visual Studio Enterprise 2017
Visit https://learn.microsoft.com/en-us/windows-hardware/drivers/other-wdk-downloads for more information.
Not exactly a solution, but Windows 8.1 WDK works with Visual Studio 2017 Enterprise,
Download it from here, just need to retarget the project to 8.1
https://www.microsoft.com/en-us/download/confirmation.aspx?id=42273
In addition, I needed to get VS2015 C++ Build Tool to fix a missing Microsoft.cpp.props error
http://download.microsoft.com/download/5/F/7/5F7ACAEB-8363-451F-9425-68A90F98B238/visualcppbuildtools_full.exe
Developing drivers to windows is quite interesting one will be exposed to advanced Operating System Concepts.The set up for the environment will be IDE
IDE - Visual Studio (https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community&rel=16)
Compilers (WDK)
Debugger (WDK)
WDK contains both(https://go.microsoft.com/fwlink/?linkid=2085767). Latest Visual Studio(VS2019) will come along with the latest WDK(10, 1903 as of now).
Sometimes plugins might not work properly i.e integration issues between Visual Studio and WDk.
By going to the location "C:\Program Files (x86)\Windows Kits\10\Vsix\VS2019" and run VSIX installer.
Now in a new project, driver related templates are available.

Visual Studio 2012 Project targeting Windows XP using MFC

I have recently acquired source code from a VS2005 project that uses the MFC library. Firstly I upgraded the project to VS2012 and I can now successfully build and run the software on Windows 8. Next, I wanted to deploy the software on a Windows XP machine.
I have set the Platform Toolset to build to Windows XP (using the v110_xp option) and I have installed the 'Visual C++ Redistributable for Visual Studio 2012 Update 1' on the target machine. When I run the software, nothing appears to happen. Via some logging functions I can determine that a call to LoadFrame(IDR_MAINFRAME) causes an exception in kernel32.dll. I can't debug any further in to LoadFrame as remote debugging on Windows XP is not available in VS2012.
Any ideas what may be going wrong? Is the Visual C++ Redistributable package the correct version to be installing on the target machine? What should I be trying next?
UPDATE
My project is already set up to use the 7.1 SDK and has minimum required version set to 5.01 in linker options.
If I use InstallShield to generate an installer and include the MFC, CRT and ATL redistributables, the installer works and my program now runs on Windows XP. My understanding of the redistributables is that they simply copy the relevant dll's in to the system32 folder (or equivalent)? Is that correct?
However, if I simply copy the files over, run the vsredist_x86.exe or use Inno Setup to install the software & dll's, my program no longer works.
I believe you have read this blog. In summary, you need to use the 7.1 SDK, and you need to set minimum required version to 5.01 in linker options.
Using the working InstallShield project and the not-working Inno project I was able to determine that the real culprit here was an unregistered msxml4.dll. The error I was receiving gave no real clue to this outcome but I got there eventually...
regsvr32 msxml4.dll

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.

Application not running on a PC with VS 2008 not installed

I have been working on a project using OpenCV and have made a face detection project.
I would like to know why does an executable created using Visual Studio 2008 not run on another pc and give the following error:
"This application has failed to start because the application configuration is incorrect"
Perhaps you need the Visual C++ Runtime package installed.
Available for download .... here
You need to install Microsoft Visual C++ 2008 Redistributable Package on the machines you are deploying your application first - http://www.microsoft.com/download/en/details.aspx?id=29
The Microsoft Visual C++ 2008 Redistributable Package (x86) installs
runtime components of Visual C++ Libraries required to run
applications developed with Visual C++ on a computer that does not
have Visual C++ 2008 installed.
Another thing to note is you will have to take the binary from Release build (not Debug.) The Debug build wouldn't run on the deployment machine even if the VC++ Runtime is installed.