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

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.

Related

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.

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

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

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.

Missing MFC71.DLL for new empty VC++ Console Project

I am trying to get an slightly older project running again. I used the code last summer just fine. Unfortunately I did not keep the VC++ project files, just the code. As such I created a new VC++ console project and selected the "empty project" option in the process. Upon adding the code and pointing the compiler and linker to the appropriate folder I compile successfully. From there I attempt to debug and receive the message
The program can't start because MFC71.DLL is missing from your
computer. Try reinstalling the program to fix this problem.
From what I see this DLL is in the Visual Studio .NET 2003 which as far as I can tell my project should have no dependency on. I am using a robotics simulation library called callisto which I suppose could depend on it. However that project seems to be gone so I can't confirm as much from the project website. How does one go about using MS development tools to determine as much? In the event that it does not, what other possible reasons would a new project depend on such an old DLL?
Note that if you are using that library in form of DLL (already compiled code that internally depends on redists of VS 2003), you can verify this by using the Dependency Walker (it is a simple .exe file that you can download here: http://www.dependencywalker.com/ and just drag-n-drop this DLL on it).
Also note that you don't need to install whole Visual Studio. Redistributable package for VS 2003 will do.
EDIT: "The Visual C++ 2003 runtime was not available as a seperate download" ~ check Where to download Microsoft Visual c++ 2003 redistributable

How to convert MVS C++ code into executable application?

So I've made a small program in Microsoft Visual Studio C++ (2008 edition) and I want to convert it to .exe format.
I know that I can find the .exe in my project directory, however it only runs fine on my own PC. When I send it over to someone else (who doesn't have Visual Studio installed or anything), it doesn't run.
I've read a little about this and it seems to be about "linking". Now I don't know anything about linking and I'm not eager to learn in depth about it right now...
I just want to make my incredibly simple program (which edits and creates text files) to run in .exe program on any computer. Is this possible, and if so - how?
Could you please guide me through the steps? I'm quite new to programming so I really need help on this one.
Thank you in advance...
The file you sent already is an exe file, but it is most likely a debug version of the program. Also, you need to see if you are linking against other DLLs, and if you are, you should distribute those with the program as well.
Since you have a simple program, it is most likely you have no other DLL dependencies, so try compiling in release mode as a first step. There will be a dropdown at the top of VS with Debug and Release, and Debug is currently selected.
You already have the .exe file that is created by linking all the .obj files that are compiled from the .cpp files you created. To repeat myself, the linking is already happening behind the scenes. However, there are two other issues. First, you may have compiled it in debug mode. In order to run your program on another Windows machine, it is best to compile it in release mode. Also, if your program uses DLLs, such as for MFC classes, then you need to copy those DLLs to the other computer as well. In order to do this correctly, you should look at creating a setup.exe file which will correctly install your program and all the required DLLs. There are tools that can help you do this, such as InstallShield.
I think you should install runtime components of Visual C++ Libraries : "Microsoft Visual C++ 2008 Redistributable Package (x86)" required to run applications developed with Visual C++ on a computer that does not have Visual C++ 2008 installed.
http://www.microsoft.com/en-us/download/details.aspx?id=29