How to package a C++/WinRT executable for installation? - visual-studio-2017

I built a C++/WinRT app and when trying to start the Release build executable I get the error
".. MSVCP140_APP.DLL was not found" followed by ".. VCRUNTIME140_APP.DLL was not found".
Obviously the runtime is installed on my development machine and I can launch it from Visual Studio using Ctrl+F5.
What more should I do to make this binary a package that can be deployed? It's an independent executable with no other external library dependencies.
I tried going through the docs and searching the web, but couldn't find any clues. I suspect executable packaging has changed with Windows 10 as I'm coming back to Windows development after leaving it during early Win 7 days.

Related

Trouble generating a deployable binary for a C++ wxwidgets project using Visual Studio

I’m having trouble generating a deployable binary for a C++ wxwidgets project using Visual Studio. After the build completes, the exe that is generated does not seem to get installed in any other Windows machine.
Visual studio 2019 is used to create GUI library with openCV included in it. I’m trying to create a standalone executable .exe to run it in any other Windows computer without installing visual studio or opencv in it.
Earlier, while opening the executable file in other computer, it gave error that dll’s are missing for openCV and wxwidgets. So, I have copied the required dll’s from the directories of openCV and wxwidgets bin folder. Now, when I try to execute the exe file, it shows the following error. Kindly help me to resolve this issue.
Applications built with the C/C++ runtimes dynamically linked (/MD[d]) require the appropriate x86 (32-bit) or x64 (64-bit) VC++ redistributables on the target machine. They can be installed from The latest supported Visual C++ downloads, or they can be included alongside the application for local deployment.
Also, be sure to only send out non-debug (Configuration = Release) builds.
MSVCP140D.dll
VCRUNTIME140D.dll
VCRUNTIME140_1D.dll
ucrtbased.dll
The 'D' suffix in the names of those missing DLLs stands for "Debug". Those are the debug C/C++ runtime DLLs, which are used by the Configuration = Debug builds, and are installed as part of the Visual Studio setup. They are to be used during development, but not otherwise deployed, per Determining Which DLLs to Redistribute:
Debug versions of applications and the various Visual C++ debug DLLs are not redistributable.
It also seems that you are using DLL build of wxWidgets and you build OpenCV as DLL.
If you yourself does not create a DLL and your software is one self contained binary ou will be better off using static linking wxWidgets and OpenCV.
And on top of what #dxiv, not everything in MS CRT can be used statically linked. That's why it is strongly recommended to install MS CRT by creating an installer, which should take care of all those dependencies.
HTH.
Thank you.

Not able to run C++ application built with VS2017 on another machine where VS2017 is not installed

I have VS2017 installed on windows 10 machine and I am building my C++ code in it. when build success I am able to run that exe on same machine. But when I am copying that exe (with all dependent DLL's) on another winodws 10 machine where VS2017 is not installed its giving error "The code execution cannot proceed because urctbase.dll was not found".
I copied those dll's (ucrtbase.dll vcrutime140.dll etc.) at the same location where exe resides and try to run it then its giving error "The application was unable to start correctly(0xc700000b). Click OK to close the application"
I installed VC Redistributable-2017 package to setup run time environment on that machine, but problem persists.
Can anyone help to resolve this issue?
it's difficult to get all the dependent DLLs of your program. I suggest you create setup project that can detect all these dependencies:
0- Put your project in release mode
1- install Microsoft Visual Studio Installer Projects from here
2- Add setup project to your VS solution
3- Add your program to the setup project
4- Choose primary output of your project
5- As you can see, visual studio detect all dll dependencies

Missing .dll in different Visual Studio versions

I recently came up with an issue. I had a project created on visual studio 2015, using allegro5 library which executed on Debug and Release mode correctly.
When I changed visual studio versions though and started using 2019 version (In the mean time I had to format my PC and re-installed only VS19) and loaded the project, the execution had a missing msvc110d.dll error shown up.
I tried to find a way in order for my project to be "upgraded" and instead of looking into the old version of msvc to try and look up the newer version, but couldn't find anything.
So is there a way for me to change some settings in order for my project to expect newer versions of msvc, or do I have to create a new project and copy paste all the configurations and files/assets inside that new project?
Thank you all
P.S I know that the error can be resolved If I get the .dll file inside that directory, but that is bad practice for sure. Also could you give me a tip on how to setup a project correctly in order to prevent those kind of issues in the future?
I think you need to find the VS2015 redistributable on Google and install it on your machine. That should solve it.
Windows dynamic library files are installed under c:\windows\system32 directory. A 32 bit dll file in a 64 bit windows can be found under c:\windows\syswow64. When your VC++ developed application searches for the dll it first checks in the application folder and then the system folder. If it is not found in these locations, a "missing dll file" error will be shown.
Normally, installing the right VC++ redistributable does the trick. But at times the mismatch persist as the sdk you're using is not in conformity with the system dll. You shouldn't replace the existing dll in the system directory manually with a downloaded( download only from www.microsoft.com) one as other installed software may also failed in the process.
In such worse case scenario, you can however directly copy the downloaded dll files in your application folder itself and distribute along your software so that it runs on a remote host too. Normally these compatible dll files, for both debug and release versions, are also available in your VC++ sdk directory which can be copied for a perfect match.

How to build an SDL C++ program for distribution?

I've been using C++ and SDL to create a program. When I build this program it works on my machine, but when I try to run it on another computer it says that all sorts of DLLs are required, and after including all the explicitly asked for DLLs the error becomes
"The application was unable to start to start correctly (0xc000007b)."
What I'm asking is: how do I build this program in such a way that it will work on other computers. I'm using Visual Studio Express 2013 for Windows Desktop and SDL 2.0.3.
I'd be happy to answer any questions.
EDIT: Both computers were running 64 bit Windows 7.
EDIT 2: I included all the DLLs Dependency Walker suggested, but still got the "The application was unable to start to start correctly (0xc000007b)" error on the other machine.
First include the SDL2.dll with the exe and other libs, then download the visual c++ redistributal 2013 and install it on that windows 7 machine, also make sure the build that you built wasn't a debug build

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.