Visual c++ problem in compiling native windows 10 application [duplicate] - c++

This question already has answers here:
MSVCP140D.dll missing, is there a way around? [closed]
(2 answers)
Closed 3 years ago.
I'm coding a native C++ application in Vs 2019 that sould be able to run on a freshly configured windows 10 machine.
The problem is that when i run my .exe app on this machine i get missing dlls error such as MSVCP140D.DLL, VCRUNTIME140D.dll etc.
I tried to install the vcredist from MSDN on the guest machine and i also tried changing the "runtime library" from the "code generation" module in the project config.
I also followed some other tutorials that i've read on this platform but i can't find nothing that really works.
I even tried to place the missing dlls in the same directory of the .exe file to register them manually, actually it does not work, but this app i'm developing should be redistributable so the user should have just to execute it.
If i try to compile my program with another compiler such as MinGw it works but i wanted to use the vc++ default compiler if possible.
Is there a way to solve this issue?
Thanks!

Maybe you used MSVCP140.DLL, wihtout the D. the D stands for DEBUG and I don't know if the Debug version version comes with the visual studio redistributable. If you compile in visual studio try to build the Release version, this should work with the DLL´s from the redistributable

Related

C++ Setup For VS Code [duplicate]

This question already has answers here:
How do I set up Visual Studio Code to compile C++ code?
(14 answers)
Closed 10 months ago.
So my teacher is wants the class to install C++, and I don't know how to do it. Please help me set it up in Visual Studio Code because it's the IDE I'm most familiar with. Please explain it in the simplest way possible.
If you are going to edit and execute on Windows, you have to install either Visual Studio regardless or g++ under MinGW. These instructions are very detailed:
https://code.visualstudio.com/docs/languages/cpp
To configure VSCode with MS compiler:
https://code.visualstudio.com/docs/cpp/config-msvc
To configure VSCode with gcc on Windows:
https://code.visualstudio.com/docs/cpp/config-mingw
Another alternative that I recommend is to use Windows WSL which is like a Linux inside Windows.
https://code.visualstudio.com/docs/cpp/config-wsl
Then install the C++ extensions for VSCode.
Then I recommend you install cmake for Windows. Although the tutorials will teach you how to build a single file, you will need more for large projects.
https://cmake.org/install/
Create a CMakeLists.txt and then use the cmake-gui to create the Visual Studio project files. All this is outside Visual Studio Code.
To build from inside VSCode I found it particularly cumbersome. I'd rather Alt-Tab and build the project manually by either calling 'make' or building inside Visual Studio. But it's your preference.
But if you are editing on Windows and running on Windows, I'd strongly suggest to run inside Visual Studio itself. Not only you will have way more support for your questions but also the Visual Studio debugger is arguably the best in the market.

How to distribute a console application? [duplicate]

This question already has answers here:
Problems with running EXE file built with Visual Studio on another computer
(6 answers)
Closed 2 years ago.
I am new to C++ and recently made a Tic-Tac-Toe game, which is a console application (no graphics). I have built my project in Release mode in Visual Studio 2019. I want this application to be transferred from one computer to another. I have zipped the Release folder of Visual Studio and tried to transfer it into another PC. When I ran it on another PC it failed to work?
I am new to programming, please help.
You don’t mention the exact error, but a first order possibility is a missing dependency.
Odds are you are missing the Visual Studio C++ runtime on the target machine (the one you are coping to). Windows does not install them by default, but Visual Studio does install them.
To download the runtime, go to https://visualstudio.microsoft.com/downloads/ then navigate to “Other tools and frameworks” then “Microsoft Visual C++ Redistributable for Visual Studio“. Select the version that matches your build and download and install it. You can copy the runtime dlls over from your PC, but installing them is generally easier and better for maintenance. If you are using an older version of Visual Studio, the download is normally available, but you’ll have to search for it.
Failing that, you may have another dependency missing. You should look to tools such as Dependency Walker, still available here https://www.dependencywalker.com/.
It must be run on pc's which OS you built on if it doesn't have additional libraries (Not Standart). if you have additional libraries, Add .dll files into release folder.
If you need help on customizing Console, I'll glad to help you on this.

Release C++ code using Visual Studio 2017 [duplicate]

This question already has answers here:
Visual Studio 2017 C++ Exe for any pc (linking vcruntime140.dll)
(2 answers)
Closed 2 years ago.
I have written a C++ project using Visual Studio 2017 in Windows 10. I am trying to run the code in other computers as well.
So, I tried copying the Release folder to another Windows 10 computer. But, when I try to execute the .exe file, it is showing errors: missing dll’s: vcruntime140.dll and ucrtbased.dll.
Please help me in the release process to be followed.
The reason is because your application is dynamically loading the VC runtime which gets installed with the Redistributable package. Typically people can install the Redistributable packages without the full SDK but the easier solution is to just compile your application to statically load the C runtime libraries.
Go to project settings, then C/C++->Code generataion and change your runtime library from /MD to /MT. /MD is dynamic and /MT is static.
Also you can just install the package on your other machine from here https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads

How to make an .exe generated by Visual Studio 2013 run in other computers? [duplicate]

This question already has an answer here:
Distributing an exe file compiled with Visual Studio 2013
(1 answer)
Closed 6 years ago.
Greetings to everyone in this forum.
I just finished my mid-term project in Visual Studio 2013 for collegue and my professor want us to give him the .exe of the project. The problem is that it only works in my computer. When I try to open the .exe in other computers, this error shows up:
The program can't start because MSVCP120.dll is missing from your computer. Try reinstalling the program to fix this problem.
I was wondering if there is any way to fix this problem, so that the .exe can work in any computer that run Windows.
I really appreciate any help you can provide.
You are dynamically linking with the C++ runtime libraries meaning you need some extra dlls to go along with your exe. You can either install the VC++ redistributable package (https://www.microsoft.com/en-us/download/details.aspx?id=40784) or static link the libraries.
If you want to keep it down to a single executable I'd suggest the static linking route. In VS2013,
right click on the project in the project explorer and select properties
In the project tree open Common Properties, C/C++, Code Generation.
Find the Runtime Library item in the right pane and change from Multi-threaded DLL to Multi-threaded.
You can do similar for the debug configuration.

Error involving dll when running C++ executable on another computer [duplicate]

This question already has answers here:
Visual C++ executable and missing MSVCR100d.dll
(6 answers)
Closed 8 years ago.
I want to share a simple program I made in VS2010 using C++, but when running on another computer I get an error. Here is the error message:
The program can't start because MSVCR100D.dll is missing from your
computer. Try reinstalling the program to fix this problem.
I have the dll in the same folder, as I thought this would fix it. I'm using the debug executable, and the other computer doesn't have VS2010 installed which is what I think is causing the problem.
Anyone have any solutions?
Target machine needs to have Redistributable Package for Visual C++ 10.0 installed. Download it from here:
http://www.microsoft.com/en-us/download/details.aspx?id=5555
You may also consider reading this section of MSDN to learn more about deployment process:
http://msdn.microsoft.com/en-us/library/zebw5zk9(VS.100).aspx
EDIT:
It seems that I missed that small 'd' in the DLL name. While this solution would be helpful in case of MSVCR100.dll (release version), it won't help you with the debug version, which you linked you application against. That's because debug DLLs are not included in redist packages - they are only shipped with Visual Studio.
Required DLLs (release builds) are placed in (VSInstallDir)\VC\redist(Platform)\Microsoft.VC100.CRT
Their debug versions can be found in (VSInstallDir)\VC\redist\Debug_NonRedist(Platform)\Microsoft.VC100.Debug.CRT.
However, I don't think that making any effort to run debug build is a good solution. Providing release build is probably what you should do.