How to set the required version of C++ redistributables - c++

I created a dll based off a sample project that is several years old.
I am building the dll and can register this dll successfully on my computer which has both 2010 and 2015-2019 C++ redistributables installed.
When I try to install this same dll on a computer with only 2015-2019 c++ redistributables installed, registration fails. After installing the 2010 c++ redistributables on that machine, the dll installed successfully.
I would like to be able to register this dll on a computer with only the 2015-2019 redistributables installed. I assume this has something to do with the configuration of the project which I'm building in Visual Studio 2019. I've poked through all the properties but nothing stands out. Would appreciate someone pointing me in the right direction!
Update: The sample I am referring to comes with the Windows sdk and can be found here: C:\Users\user\Source\Repos\Windows-classic-samples\Samples\Win7Samples\winui\shell\appshellintegration\RecipeThumbnailProvider
When I opened it up in Visual Studio 2019 it did some kind of update, but doesn't seem to have affected the redistributable it depends on.

This ended up being related to the fact that I'm using JNI and was dependent on jvm.dll. I was using the jvm.dll from Java 8u202. This version of the dll is dependent on the 2010 C++ Redistributables. Starting with Java 8u261 jvm.dll is dependent on the 2017 Redistributables (source).
Dependency Walker is outdated, but this newer tool, Dependencies, worked with my dll.

Related

C++: MFC Application on both Windows 10 x64 & Windows 7 x64

I'm building MFC Application with CLR which can run on windows 10 x64 & windows 7 x64 and execute without installing Visual Studio.
First, I've tried to find a solution for app without installing visual studio.
After some works on google, I found some clues to this issue.
Release build doesn't require installing Visual Studio.
I was building the project on windows 10 x64. So the release version can work on other windows 10 pcs without Visual Studio.
But it can't work on Windows 7.
So I've got stuck in search on this issue until now and I found something.
"Build applications for both Windows 7 and Windows 10 with Visual Studio 2015" is a thing I found here.
The answer is right thing I've tried.
On their comment, I saw one word - CMake.
I'm not sure that I can accomplish my solution with this - CMake.
Is there someone to told about this thing?
Or anyway to fix this issue?
Thank you.
CMake won't help you.
I think you'll need to install Visual C++ Redistributable for Visual Studio 2015 on any machine where Visual Studio was not installed, if the redistbutable package was not installed yet.
You also need to use .NET framwork which installed on both machines, I guess .NET 4 is good enough.
EDIT:
Try to run your exe from a console, and check if there is some print for missing dll or something.
Anyway, you can use dependency walker to check if you're missing some dlls, (download the x64 version) drag&drop your exe into it and check what prevent it from run.
Now, I found right solution about this m own question.
As a matter of fact, #SHR is helpful for this answer, but there's something to modify for right solution.
Installing .NET 4.0 is right and it's mandatory for working on Windows 10 & 7 x64.
But "Visual C++ Redistributable for Visual Studio 2015" should not be necessary.
Without these packages, the app can executes on windows 7 & 10 x64.
Of course, the app requires some dlls in C++ Redistributable packages. But not all.
So I put dlls the app requires at the same directory of .exe file.
That's all.
There's no other requirements.

VC++ Redistributable 2012 or 2013 or 2015?

I have an application written in QT. Previously I was using Visual Studio 2012 and Qt 5.3.1 after which I recently upgraded to Visual Studio 2015 and QT 5.6. I would previously provide msvcp110 and msvcr110 as part of the installation (I know that wasn't the best practice but I got away with it).
After upgrading I had to now install VC++ 2015 because of the changes with VS 2015. I don't mind the changes and currently providing redist packages to be installed.
The problem I am facing is that, I do have to provide VC++ 2012 as well and recently running the software in Windows 8.1 Pro, I was asked to provide VC++ 2013 as well (never used VS2013 for compiling). The diagnosis was from dependency walker and google. Not only that, I had to install x86 and x64 of all the 3 versions of VC++ for the software to start (wouldn't even start to be honest).
Why do I need VC++ 2012 and 2013 when I now use only Visual Studio 2015?
How do I get rid of the other redist packages? Is it some code I have written which is dependent? If yes any chance I can find out?
Why do I need to provide both the 32 and 64 bit versions when I compile strictly in the 64 bit compiler?
Any way to diagnose without dependency walker? Can there be some logging when the application refuses to start at all?
Apologies for the long post, but any light here can restore my sanity.
Thanks in advance.
You are using DLLs linked to the older runtime. You can use Dependency Walker on your development machine to track this down, shouldn't need to install any tools on a customer machine for that.
Migrate all the files shipped with your application to a version built against VC++ 2015.
You didn't provide any details that could reveal the reason.
For DLLs other than the language runtime library, you can use delay-loading and then be able to trap failure to load the library. You can't effectively delay-load msvcr*.dll though. One option would be to create a very thin EXE that uses no support DLL at all (either use pure Win32 API, or statically link the runtime) which does nothing except install an error handler and then load your main program which is now in the form of a DLL. Loading your main program DLL should be done either using delay-load linking or LoadLibrary()+GetProcAddress() -- either one will allow catching errors. This main program DLL would be free to import the runtime DLLs as usual.

MSCVP120D.dll missing even though redistributable is installed?

I'm creating a C++ application using Visual Studio 2013 and using libraries such as FMOD and SDL. I'm trying to package the application to run on other machines through the .exe. I have all my library paths correct and dependencies referenced locally, but when I run the .exe on another machine I get the "MSCVP120D.dll not found" error.
I have installed the Visual Studio 2013 redistributable on these test machines (Since it's 120.dll) and yet the error persists.
As far as I'm aware, other than the libraries specified, which all work, I'm only using standard libraries and windows.h.
I have been told another option is to install the dll file locally and link it statically to the CRT, but honestly I don't know enough to know if this is a correct option or not.
For more information, I'm on a Windows 8.1 machine and have tested on Windows 8 and 7, with no success other than on my own machine.
You are compiling your program in debug-mode and linking to the MS C++ debug-runtime.
Change to release-configuration, and either compile it statically or preferably add the Visual C++ Redistributable Packages for Visual Studio to your deployment (the last part is not neccessary if it's already installed).

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

LoadLibrary fails with error code 14001

I'm using Visual C++ 2008 Express Edition to create a resource only DLL.
The problem I'm facing is that running the application that makes use of the DLL
on another computer besides mine results in LoadLibrary() function failing with error code 14001.
Searching throught the internet it seems to be a dependecy problem of the computer
running the application lacking libraries of the Microsoft Visual C++ 2008 Redistributable Package.
My first step was to install the latest Microsoft Visual C++ 2008 Redistributable Package but that didn't solved the problem.
Also I changed my project setting so the DLL compiles with static CRT linking assuming that
this way I will get rid the dependencies.
These options seem to be the workarounds for other people having the same issue.
Any idea in which direction to look is highly appreciated.
Thanks
==================================================================================
Thanks for your answers.
Both Dependency Walker and the event viewer indicated a side-by-side configuration
problem as I was missing a debug version library of the VC++ Redistributable Package.
I was careless and have compiled my DLL in debug mode, recompiling in release mode solved the problem.
Try to isolate missing library by Dependency Walker:
http://www.dependencywalker.com/
Just run your application on the second computer with this tool, it should tell you what library is missing. Be sure you are installing the right version of Visual C++ 2008 Redistributable Package; there are two of them, for VS 2008 with SP1 and without any SP...
Look in the eventviewer. Good chance there will be an error there from Windows SideBySide explaining which assembly is missing.
Likely it would be a VC CRT runtime which you will have to bundle with your dll.
(the VC redistributable is available here: http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=29)
I had the same issues but with Visual Studio 2013; a debugging set of DLL's which required a manifest. In my case Microsoft.DTfW.DHL.manifest and dbghelp.dll had to be added to the path (I used the exe directory).