Release build fails to start due to missing ucrtbased.dll - c++

I'm facing a weird problem.
Using cmake-3.24.2 I have built a windows application (windows 10) with c++20, in release mode. (Visual Studio 2019, x64) The application runs fine on the machine it was built.
When deploying the same application on another windows machine, it was failing to start showing an error about missing ucrtbased.dll (and subsequent vcrt debug dlls). I'm actually confused why a release build looking for a debug dll. I used dependency explorer to see if the application was linked to any debug dll and I could not find any.
Google search showed the ucrtbased.dll is part of windows sdk. The windows sdk was not installed on the target machine. Is the windows sdk needed to run the application (I thought vcruntime was sufficient).
Also the same code works fine if I used c++17 standard and deployed on the target machine. I'm wondering if there's something I'm missing with c++20.

The solution is mentioned here.
Ran dumpbin on every dll my executable is dependent on and found out the culprit

Related

How to execute MFC application on any pcs

I'm trying to release the mfc app which can execute without installing visual studio 2015.
First, When I'm on google, this suggested that I can execute like above by installing vc++ redistributable package.
So I've installed packages but it doesn't work.
And I got the error message. The message is like - "The program cannot start because of missing mfc140ud.dll. ...."
Second, someone said that the release app instead of debug mode can be executed without visual studio.
So I compiled the app on release mode, then I didn't get the error message but it doesn't executed. What's wrong with this?
What can I do?
You distributing a DEBUG version of your application. You can tell that by the name of the DLL it says it can't find. The "d" suffix of "mfc140ud.dll" indicates it's looking for the DEBUG version of the MFC libraries. I don't think that the redistributable contains debug version. Nor should it.
Try releasing a RELEASE build to your clients.
Your application don't run on other PC because is the debug version, compiling to release and distributing on other PC having the visual studio redistributable package will do.
If you want your application to run not depending on the mfc140u.dll you can simply static link your application with MFC. This is easily accomplished going into your project properties.
Your application exe will be bigger but you won't have to bother with these kind of errors anymore. Please note that while this method works on debug too you better not distribute debug code on other machines for a number of reasons.

how to add statically link run-time assemblies?

i am trying to run an exe file on another computer that doesn't have visual studios installed.
When i try run the file i get the error : This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem.
I tried searching for the answer and i lot of websites mention static link run-time assemblies
but i have no idea how to add them into my project.
(Program is in visual studios 2008 in c++ console)
It is hard to tell exactly what libraries are missing. Here are some ideas.
You are deploying a debug version. As non-development computers typically don't have debug libraries deployed (mfc*xxxd.dll & co.) your app cannot start. You should deploy the release version.
You app is built with newer version of C runtime or MFC which is not available on target machine. You should install Visual C++ redistributable package for your version of VS / development tools.
If you can't install this, you should statically link runtime/MFC libraries to your app. Depending on your version of VS, you need to go to project settings and check correct version of runtime libs (static vs dynamic)
If still there are issues, you should check exactly which dlls are missing by using a tool like Dependency Walker on the target machine (actually this should always be the first thing you should do instead of guessing). It will show you which dlls are missing. If everything seems OK, then you are missing some delay-loaded or COM dll - this are not loaded on startup but on demand. You can use DependencyWalker to profile the startup of the app to see exactly what's missing.

Side by Side manifest issue with VS2005 & VS2008

I have a C++ project I am building in VS2008. This project also links against a library (DLL + Import lib) that was built using VS2005 and thus loads VS2005 debug CRT library (everything is a debug build).
When attempting to run this executable built in VS2008, I get an error on loading due to that VS2005 DLL not finding the Debug CRT libraries, even though I have VS2005 installed with SP1. I've checked Windows updates too, so I'm not really sure what more I can do.
How do I diagnose this problem? I've looked at the Event Viewer in Windows and noticed that it can't find the debug VC80 CRT library, but that's all I know. There's a version mismatch somewhere in here I guess, I just don't know how to fix it since I don't know much about this manifest/side-by-side stuff.
The OS I'm building on is Windows XP 32-bit. I have VS2008 SP1 and VS2005 SP1 installed (so all debug manifests/CRT dlls should be available)
Learn to check or create or check appropriate assembly manifests.
Here is more info once you get that done.
On Windows XP, if an external manifest is present in the application's local folder, the operating system loader uses this manifest instead of a manifest embedded inside the binary. On Windows Server 2003 and later versions of Windows, the opposite is true—the external manifest is ignored and the embedded manifest is used when present.

Error "msvcr100.dll" (only on Windows 7 & Vista) even AFTER statically linking (/MT)

I have a simple dll that is being injected into a target process using MS detours. The process doing the injecting is C# .net application.
Both the DLL and the detours library have been statically linked (/MT option).
However when I try to inject the dll into a target program on a client's machine I get error "msvcr100.dll" is missing" error. Now I open the dll w/ depends and there is no dependency on "msvcr100.dll".
Even weirder this issue only happens when the client is vista x64 or windows 7 x64. The dll is successfully injected on windows xp x32 and windows 7 x32 systems.
Any ideas on what bug in visual studio is indicating a dependency on a library not being used?
On edit:
Looks like someone else had the same issue ... never resolved.
Compiled .dll files requiring msvcr100.dll to load
For the record installing Visual studio 2010 C++ redistributable on client machine "solves" the issue however I hoped to avoid that dependency by statically linking.
You might be able to figure out what's going on my attaching (pre-injection) the cdb debugger to the process on a machine where msvcr100.dll is loaded (with the DLL installed). Use the
sxe ld:msvcr100
command to break when that DLL is loaded (I'm not 100% sure if that's the exactly correct syntax). Once it's loaded, you might be able to figure out why by looking at the call stack. If not, try setting a breakpoint on everything in that module:
bm msvcr100!*
and see who's calling it. That should give you a really good idea why it's being loaded.
So I never did discover exactly what the issue is but on a hunch I tried running the application (exact same build w/ mscvr100.dll error) on another Windows 7 machine and it worked fine.
I reinstalled Windows 7 on the "problem" machine and the same build works fine without error. In my google searching I came across a report of another person having this issue after uninstalling Visual Studio. I know for a fact that Visual Studio was installed on the "problem" Windows 7 machine at one time and was currently uninstalled.
If this happens to someone else I would recommend try running the binary on a machine that has never had visual studio installed. If it works without issue then likely there is some issue related to VS uninstall.

Compile (?) issue. Visual studio c++ 2008

There's an app that I use on an XP netbook for tuning a car. It was working just fine. Then I needed to make a simple modification (output to STDOUT instead of to file) so I got the source from the author.
My netbook doesn't have the space for a compiler. I have Visual Studio C++ 2008 on a Windows 7 desktop. I made the adjustments, compiled and tested on the desktop and it worked perfecty. So then I copied the executable to the netbook and it won't run
"This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem"
Original (precompiled) exe works fine. To rule out my changes, I compiled the source without the mods and it still didn't work. The executable works fine on the 7 machine as well as another Win Vista machine I tried.
So its obviously something with the XP machine and the way the executable is compiled. I really have no idea how this stuff works so I don't know what to try.
Couple of ideas:
As Keith said above this is DLL/manifest issue.
Get Visual Studio 2008 redistributable (for matching application platform) and install it on the netbook.
If this does not help: Use Dependency Walker to find out what other DLLs you are missing.
Its because a dependency / DLL compiled into your application doesn't exist on the platform you are running on.
Open windows event viewer and view the application log. There will be an entry for the error and the name of the DLL which is missing. Copy / Install that DLL on your target platform.
I would guess your vc runtime has changed with visual studio 2008 and you need to copy the latest version to your target platform. If you dont know where to get the dependency DLL, post the name here and we can see what we can do about it.
You can check your project settings and make sure to use a statically linked runtime instead of a DLL.
Project Settings, C/C++ -> Code Generation. Make sure you're using a runtime library that isn't a DLL. (So Multi-threaded Debug instead of Multi-threaded Debug DLL for example).