missing libgcc_s_sjlj-1.dll runtime error - c++

I can compile my program in Code::Blocks 13.12 (MingW (haven't tried other versions)) and run it within the IDE.
However, when I attempt to run the program outside the IDE I get
libgcc_s_jlj-1.dll missing
Reading around I have tried adding
-static-static-libgcc-static-libstdc++
to my linker settings (individually and I used the last two together) which doesn't work
If I copy the .dll files to the same folder as the .exe it presents
libstdc++-6.dll missing
to my attention. If I copy /that/ .dll too the program will run just fine; however, I'm not sure the legality of moving the .dll with my program, and I want distribute my program easily to others so the static option I read about seems preferable.
(side note: I shouldn't have this error so I'm curious as to what I'm doing wrong)

Related

DLL Error Following the tutorial for gtkmm

I'm following the gtkmm tutorial for gtkmm4 and I'm getting an odd error when I try to run my program. The program is an exact copy of the provided code, and it compiles successfully:
However, when I run the program it gives me a series of errors:
I'm not sure what to do at this point. I've tried googling, but I don't get anything helpful. I've check that the DLL in question does exist. Any advice is appreciated!
Edit: I ran the Dependency Walker program, and got some errors, not sure what this means though.
Edit2: I did some research on Dependency Walker, and it seems to have some known issues, so I also ran lucasg's "Dependencys" program, with this output. I'm still not really sure what this means, but it seems fine.
Edit3: I moved the 4 offending dll files into the build directory, and these are the new errors I'm getting. Its the same error, but now it points to the more local file.
Check your .exe file with Dependency Walker to see which issues there are loading the .dll files.
One possible cause could be that you're mixing 32-bit and 64-bit.
The issue was something to do with finding the correct DLLs. The solution, as outlined here, is to copy all the DLLs from C:\msys64\mingw64\bin into the build directory. Then, using ntldd or some other profiler, determine which DLLs are unnecessary and remove them.

Program works in CLion IDE, but exe doesn't work

I started programming in C++ using CLion IDE.
When I run the program inside the IDE it works. However, opening the .exe file outside the IDE generates a bunch of errors:
The code execution cannot proceed because libgcc_s_seh-1.dll was not found. Reinstalling the program may fix this problem.
Hitting OK pops the same message again with a different dll.
Why does this happen? What are the different ways to fix it? What is the best option?
You always need to ship any libraries your application is linked with along with your application. The libraries are just as much a part of your app as the code you wrote yourself. This includes your compilers runtime libraries (which you forgot in this case).

SDL_Window was not declared in this scope

I'm doing a tutorial on SDL, and I'm having some issues
I just did this where I do the basic stuff to get SDL to run. I then ran the test code (which is on that page) and it worked. However, now I'm trying to run the code here, and it's giving me this list of errors.
What could be the problem? There was one weird thing, I don't know if it's relevant, to get the first code running I had to put SDL2.dll in the SysWOW64 folder even though both my compiler and version of the library are 32-bit. Again, I haven't a clue whether that could mean anything, especially because I got the first thing to run perfectly.
Edit: Also, Code::Blocks shows me the error in SDL_platform.h, a file completely identical to my 01_hello_SDL.cpp. I'm a complete noob to SDL and even though I have done some pure C++ I haven't used it with an external library before, so I have no idea what that means.
Edit: Here's my setup:
I copied the contents of the 32 bit folder to C:\mingw_dev_lib\sdl, resulting in C:\mingw_dev_lib\sdl\bin, C:\mingw_dev_lib\sdl\include, C:\mingw_dev_lib\sdl\lib and C:\mingw_dev_lib\sdl\share.
I copied SDL2.dll to both C:\Windows\System32 and C:\Windows\SysWOW64.
In Code::Blocks my setup is like this: In build options, in the linker settings tab I put -lmingw32 -lSDL2main -lSDL2. In the search directories tab, in the Compiler subtab I have C:\mingw_dev_lib\sdl\include\SDL2 and in the Linker subtab I have C:\mingw_dev_lib\sdl\lib.
This got the test (which you can find at bottom of the page of first link) to work. However, the second program (at the bottom of the page of second link) gives me the errors in the third link.
First of all you need to put SDL2.dll in the SysWOW64 folder because you're linking SDL2 dynamically and when you execute the program it needs to find the SDL2.dll file in basically two folders:
The folder where the program resides.
System32 (or his 64 bit counterpart SysWOW64).
Therefore i can't give you an accurate answer based on the compilation errors you get, please show how you're including SDL2 and the Code::Blocks configuration.

missing sfml-graphics-d-2.dll when using SFML

I am coding in C++, using the SFML, since a little bit of time and everything has been running fine.
This morning I've been using the type sf::Image and some functions on that type, such as getPixel.
Then, the compilation works fine, however, when I try to run it, I get the missing dll error on sfml-graphics-d-2.dll.
I looked in the folder and I could see that indeed, there was no such dll! There was his brother sfml-graphics-2.dll instead however.
Why is it asking for the dll that I don't have :( ?
Informations:
I use code::blocks.
Linkers seems to be ok :
"C:\Program Files (x86)\SFML-2.3\lib\libsfml-graphics-d.a" for the debug
"C:\Program Files (x86)\SFML-2.3\lib\libsfml-graphics.a" for the release
I use the SFML2.
I'm on Windows 8.
My compiler is GCC MinGW.
I can't find sfml-graphics-d-2.dll on my computer (because I had to compile the SFML using Cmake, and it only generates files like sfml-graphics-2.dll, not like sfml-graphics-d-2.dll)
Thank you very much if you can help! :-)
The -d in sfml-graphics-d-2.dll stands for debug, so when you are building SFML, you need to change the build target from Release to Debug.
The Debug build target should have been generated by CMake when you ran it.

How to run C++ program that use PDCurses on other computers?

I've recently started using PDCurses in a C++ game I'm working on. When I compile the program on my own machine (windows) and run the .exe, everything works as it should.
When I take that .exe onto a different computer that doesn't have PDCurses and I try to run it, I get an error about a missing pdcurses.dll file.
After doing a bit of research online, I found out that including the .dll file along with the .exe should make it run but it didn't work for me.
This is how I compiled the program using MinGW: g++ game.cpp -o game -lpdcurses
So my question is, how do I make this program run on computers that don't have PDCurses setup, and also, is there a way to do this by combining the .exe with whatever additional file(s) the system needs to run the program? I've also read that you can do some sort of static linking but so far I've been unable to find a way to do this.
Thanks in advance for the help.
NOTE: In case it matters, I setup PDCurses following this tutorial: http://comptb.cects.com/1848-adding-pdcurses-to-mingw
Not sure if that was the best way to do it but I'm able to compile and run C++ code that uses pdcurses on my computer fine.
Sorry for not posting the exact messages. Here they are:
The first one I got when I didn't include the pdcurses.dll file along with the executable said :
The program can't start because pdcurses.dll is missing from your computer. Try reinstalling the program to fix this problem.
The second one I got after I included the pdcurses.dll:
*The program can't start because libcc_s_dw2-1.dll is missing from your computer. Try reinstalling the program to fix this problem.*
You need to include all the dynamic libraries you linked with. Be careful of licensing, although IIRC there's not much that will bite you with MinGW.
There should be a 'ldd' command if you have the MinGW shell. Try running it on game.exe and it will tell you what libraries you need to run your program. You need to include them all with the exe.
If you want to try and remove the dependency nightmare you can use the static linking (-static) option to your gcc link command. You may not be able to actually do that if you don't have the static versions of your libraries installed. This has other implications - your exe will be bigger and the OS's shared shared page code will not work because it can't tell what parts (DLL code) you are sharing with other apps. In effect, your application will use more memory as a result, although it may be insignificant.
Another option is to get the sources to PDCurses and compile it as a static library. That way you don't have to get involved in the DLL Hell.
Compile it as a C library instead of a C++ library and you should be good to go.