How to make a C++ Application in Visual Studio 2015? - c++

I made a small C++ game in Visual Studio 2015 using the SFML library and it works perfectly fine when I click the '► Local Windows Debugger' button in 'Debug-x86' mode.
My game does not work on anyone else computer because it says the next dll files are missing:
msvcp140.dll
msvcp140d.dll
vcruntime140d.dll
ucrtbased.dll
appcrt140d.dll
desktopcrt140d.dll
I know those files comes from the Visual Studio 2015 Instalation, but for those who do not have VS installed what can I do to fix those problems?
I copied the first 4 dll from my PC C:\Windows\System32 (msvcp140.dll, msvcp140d.dll, vcruntime140d.dll, ucrtbased.dll) on the exe path but couldn't find the last 2 in nowhere. (appcrt140d.dll, desktopcrt140d.dll)
I have no idea how to make an exe aplication with all its dll dependencies.
When I use the 'Release-x86' mode it throws the next error by the way.
Exception thrown at 0x62234AE7 (vcruntime140d.dll) in Timber.exe:
0xC0000005: Access violation reading location 0x00000000.
If there is a handler for this exception, the program may be safely
continued.

I fixed it by configuring the release mode of the SFML library in the project's properties and by switching to 'Release-x86' mode instead of 'Debug-x86'.
You can read more about how to configure your SFML projects here: https://www.sfml-dev.org/tutorials/2.4/start-vc.php

Related

MyProject.dll is not a valid win32 application

I have copied a C++ solution folder written with visual studio 2013 to my Pc and tried to run it (I mean VS Debugging) with VS 2022. the solution Contains 5 projects but I just target one of them so unloaded the rest and set the one as Startup project and this error happened.
Error Image
Solution file is working well on first pc and project is not a win32 project its x64 (I don't know much from win32 or x64).
Unable to start program. [VALUE].dll is not a valid Win32 application error in Visual Studio 2017
According to this question I tried selecting project, setting as startup, repairing VS, installing vcredist_x64 but non helped.
After Running, VS make Debug folder in solution Directory not the project "LP_Dll\x64\Debug" (LP_Dll is the solution name) without any .exe file, and the error path is exactly this folder, can it be from that?
Project properties the "Configuration Type" was mistakenly changed to .dll.

program .exe run on cygwin but give exception on debugging and running on visual studio

I can run my program when I call it from cygwin.
but on visual stdio when I want to debug it, I get following exception:
Exception thrown at 0x610DDA44 (cygwin1.dll) in .exe: 0xC0000005: Access
violation writing location 0x00000000.
If there is a handler for this exception, the program may be safely continued.
I added my cygwin1.dll path to my project environment but it didn't work.
I am trying to build and run canfestival from this link : https://canfestival.org/code
please help to solve this exception.
As Scheff has said, using vs and cygwin in combination is not recommended. then I tried hard to make my library file in visual stdio, and it is debuggable without cygwin now. Also many people suggested using debugger for cygwin such as GDB if making library with visual studio was not possible.

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).

The file MSVCP100D.dll is missing from the computer

What I'm having is that this error is displayed when I wanted to copy a exe debug project that I have created (which works witout any problems) to another machine (the error message is displayed).
According to the question posted previously, the best solution to get rid of the error message is to make a release and not a debug in the Configuration Manager.
Doing that, and when rebuilding the project with the RELEASE one, I'm having new errors in my project which were not included when doing the DEBUG.
For instance, one of them is :
Error 2 error C1083: Cannot open include file: 'opencv\highgui.h': No such file or directory c:\...\projects\...\ex\opencv.h 4
23 IntelliSense: identifier "IplImage" is undefined c:\...\ex.cpp 80
Any feedbacks?
You've probably added include paths for OpenCV to your project file. Unfortunately, Visual Studio by default makes such changes ONLY to the active configuration, which in your case was debug.
This rarely makes sense. Adding a logging library would be such a rare case, but you probably needs OpenCV in both debug and release builds.
MSVCP100.dll is part of the Microsoft Visual Studio 10 runtime. MSVCP100d.dll is the debug build of the same dll - useful for running your program in debug mode.
http://www.microsoft.com/en-us/download/details.aspx?id=5555
Basically it is a relatively new package and is not guaranteed to be on all systems, especially Windows XP, so you can distribute the required DLL files or the entire runtime with your program. EDIT: Keep in mind that debug builds are not meant to be distributed, so your program should not contain debug dll-s either such as MSVCP100d.dll.
Try downloading it, and then see what happens.
Also check out this question.
MSVCP100D.dll and MSVCP100.dll is part of the Microsoft Visual Studio 10 runtime, so if someone compile her/his programs with this package, then uninstall the package and install another one for example Microsoft Visual Studio 12 (2013).
When trying to run her/his programs , then her/his will get the message that 'so and so... try to reinstalling the program to fix this problem'. this means you have to reinstall Microsoft Visual Studio 10.
the other way is to recompile your programs under the new package!

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

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.