Visual Studio 2010 C++ SDL game works on the computer it was compiled on, but not on any other - c++

I have coded a game of noughts and crosses in C++ using SDL and Visual Studio 2010. I have built it in Release and it works no problem if I run the .exe on the computer I compiled it on (Windows 7 64bit Home Premium).
I tried to run it on my laptop (Windows 7 x86 Home premium) and it opens up an SDL window and immediately closes. I found it was crashing when loading a particular file so added a console output to the initialisation code and turns out it is this file it can't find:
if((menuSurface = Surface::Load("gfx/menu.png")) == NULL){
std::cout << "menu Did not load.";
system("pause");
return false;
}
Peculiarly this is the second file loaded and the original computer can find it fine.
Problem above has been solved! I simply forgot to add the extra .dll files that came with sdl_image such as zlib1.dll, libpng12-0.dll etc... Second problem still persists.
Additionally on my friends computer when I run it, it comes up with this error
TestWin32.exe – System Error
The program can’t start because MSVCR100.dll is missing from your
*computer. Try reinstalling the program to fix this problem.*
I included the MSVCR100.dll file in the same folder as the .exe (along with the SDl.dll and SDL_image.dll) and still no joy. The file is present in his SysWOW64 folder but the program isn't picking it up. Can anyone see what may be causing this?

The first problem is likely an issue with the resource not being at the correct location.
The second problem is that with the new Microsoft C runtime DLLs you cannot just include it, you need to deploy the appropriate redistributable for Visual Studio 2010.
You can find that (x86) here. There is also a separate x64 version if you need it.

This is probably the most helpful tool for identifying which libraries you forgot to ship with your program:
Dependency Walker
It was originally included with the Windows SDK, but that website has updated versions.

install microsoft vc++ redist on target machine, have had trouble just trying to copy msvcr100.dll/msvcp100.dll too.

Find out what DLLs your executable is dynamically loading, both on your development system as well as on the other systems.
I suspect that some DLL is being loaded that shouldn't be, e.g. a library's DLL in a wrong version.

Related

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.

C++ program not running on windows systems without VS installed "VCRUNTIME140.dll was not found"

When I compile a simple program:
#include <iostream>
using namespace std;
void main() {
cout << "Hello world!";
}
And tun the compiled .exe on another system without visual studio installed I receive the following error:
The Code execution cannot proceed because VCRUNTIME140.dll was not found. Reinstalling the program may fix the problem.
When I compile with cl.exe I receive no errors,
does anyone know a workaround to this without installing VCRUNTIME140.dll on the systems. (I've tested on multiple windows systems including a windows virtual machine)
I've encountered this problem before and there's a simple solution to it,
The missing .dll are a issue of static linking not missing packages (in most cases),
becuase visual studio 2019 comes pre-installed with what you need.
To fix:
go to your project properties (in project tab)
Select C/C++
Change the value of runtime library to "Multi-threaded debug (/MTd)"
This will cause the compiler to embed the runtime into the app.
The executable will be significantly bigger, but it will run without any need of runtime dlls.
Get the "Visual Studio 20xx VC++ Redistributable package" for your version of Visual Studio. Then run on the target machine to install.
Bottom of this page: https://visualstudio.microsoft.com/downloads/
Or bottom of this page for older versions of Visual Studio: https://visualstudio.microsoft.com/vs/older-downloads/
I've had the same problem, mainly because originally when compiling something with C++ and turning it into an exe file, it's still gonna be an exe file that depends on libraries from C++.
But according to asd plourgy, who had a good idea to change the value of the runtime library, I wanted to share with whoever seeks knowledge how I solved it:
Go to your Visual Studio Code and follow these steps:
Click on Project
Properties
Scroll out C/C++
All Options
runtime library
Change value to: "Multithreaded-DLL (/MD)".
And that should do the trick. Afterwards, you have to obviously
save
debug
create new(exe)
open cmd and run the exe to make sure it works.
My System is: Windows 10
Here are a few pictures to make the steps easier, it's in german though:
step1:
step2:
step3:
step4:
step5:

Using VS2015 Express, deleted VS2013 Community, can't run "MSVCP120d.dll missing"

As per the title. I had VS2013 Community installed, I had started a project on that and then moved on the VS2015 Express and converted the project. Recently I needed extra space on my machine so I deleted 2013C using Add or Remove Programs, but now my code gives an exception immediately on running, saying "The program can't start because the MSVCP120D.dll is missing from your computer. Try reinstalling the program to fix this problem." I went and installed the VS2013 redist, and the problem still persists. Is it possible to solve this without reinstalling the entirety of VS2013?
The odd thing is, the DLL it's looking for is a debug DLL, and I'm running the .code in release mode, and I did check, the runtime library is /MT not /MTd
The .dll doesn't exist in my /Windows/System32 folder despite me having installed the redist.
Edit: I found a copy of the dll and installed it but not the code just doesn't run, it doesn't give the same exception but it just says failed to start.
The d library is not "redistributable" and only exists in the development environment.
My recommendation is to use the depends tool (drag executable into depends.exe and it shows the dll dependency), which is part of the windows kits SDK to open your executable.
That should highlight a DLL which was built with the earlier 120d configuration, and can be re-built.
I think the VS 2013 is a side-by-side assembly, and has very strange locations (windows\system32\winsxs).

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

MSVCR100D.dll error at runtime

Ok , so i created a program using VC++ 2010. it ran just fine.
Got to work and could only install vc++ 8 due to having a crappy computer that is still stuck on xp sp2...
Everything will link up and build with no errors, But when the program starts to run i get "This application has failed to start because MSVCR100D.dll was not found"
I tried changing the runtime libary from MDd to MTd but still no luck...any idea?
That DLL comes with Visual Studio 2010. If you want to use your program, you'll somehow have to get your hands on it. If possible at your work, you can download it. Another (probably better) option would be to take it with you from home on a USB drive.
Edit: You can also try re-creating the project, and then copying the source code over into the new project. Your newly created project (in Visual Studio 2008) should not be depending on that erroneous DLL.
Edit 2: As Hans Passant added in a comment, this DLL is needed by Debug compilations of your program. So if you simply compile as Release, you can safely ignore the first part of my post. (I hope I'm not breaking gentleman rules by adding this to my post.)
MSVCR100D.dll is for debug mode, and is installed with visual studio 2010, since 2008 has MSVCR80D. You can just google that and download it, and put it in the same direcrory, or just complie in release mode.
here is a download link. You need the small download zip file button, not the big ones.
http://www.dll-files.com/dllindex/dll-files.shtml?msvcr100d
As I know, MSVCR100D is debug version of runtime library used by VC2010。So, if your point either is:
(1) you do not have that dll which you really need, you can download at http://www.dll-files.com/dllindex/dll-files.shtml?msvcr100d or
(2) you want to run that program without requirement of MSVCR100/D.dll, you may need to recreate a project in VC8, then substitute with your source files (not solution file or other files managed by Vistual Studio).
FYI: If my memory were not going wrong, I remember that a project created by higher version of VS cannot be opened directly by lower version one. So, how did you build them?