0

I'm learning C++ and I have completed a basic Hello World program. The program runs fine in my IDE, but I am unable to run it from my Windows console.

I am using the MinGW compiler.

I have already added it to my path.

I am using Windows 10.

I am using the Eclipse IDE.

When I try to run my program, I get the error that

The code execution cannot proceed because libgcc_s_dw2-1.dll was not found. Reinstalling the 
program may fix this problem.

I double checked the bin folder in MinGW and it does have the libgcc_s_dw2-1.dll file. And, as I said, MinGW is set to my path.

I know that there is a question like this already but those solutions did not help me. Any help would be much appreciated. Thank you.

EDIT: my compiler bin directory has been added to my path.

Andrew
  • 195
  • 2
  • 12
  • Check the path from the console, type the command `path` and check that the folder containing the dll is listed. – john Jun 30 '20 at 14:03
  • 1
    Get rid of mingw, eclipse and, generally, all *nix developer tools ported to Windows are outdated, they will only cause uneccessary trouble and should be avoided unless there is a reason to use them (say, developing a cross platform app). – Michael Chourdakis Jun 30 '20 at 14:10
  • This error indicates missing redistributable packages. – new Q Open Wid Jun 30 '20 at 14:23
  • @MichaelChourdakis What's so bad about it? The latest versions of common tools are available (latest GCC, Clang, `make`, and what not). – HolyBlackCat Jun 30 '20 at 14:25
  • You certainly have picked a difficult path. MSVC 2019 with a Desktop C++ workload configuration would've worked out of the box.. having said that, have a look [here](https://stackoverflow.com/questions/4702732/the-program-cant-start-because-libgcc-s-dw2-1-dll-is-missing). – rustyx Jun 30 '20 at 14:25
  • @rustyx To be fair, MinGW requires minimal configuration. Adding a compiler directory to `PATH` is not hard. – HolyBlackCat Jun 30 '20 at 14:26
  • @MichaelChourdakis I am following a C++ tutorial that uses those tools so I'd rather stick with them. – Andrew Jun 30 '20 at 14:50
  • Tutorials are very bad for learning C++. You need proper books and a good teacher. – Michael Chourdakis Jun 30 '20 at 15:23
  • @HolyBlackCat a debugger, intellisense, and most important, the updated SDK. Direct2D, ribbon,sensors, animation editor etc. It's only useful for the raw beginner and still, VS 2019 is free. – Michael Chourdakis Jun 30 '20 at 16:17
  • @MichaelChourdakis The Windows SDK (and related tools) is a valid point. We do have decent IDEs though, with intellisense-like features and visual debugging support. (But maybe not as polished as VS.) So, "for the raw beginner" and for those who don't need the SDK. – HolyBlackCat Jun 30 '20 at 17:11

1 Answers1

0

I double checked the bin folder in MinGW and it does have the libgcc_s_dw2-1.dll file.

Add your compiler bin directory to PATH.

OR copy this .dll to the directory where your .exe is. You'll have to do the same thing for libstdc++….dll and probably also libwinpthreads….dll.

Note that if you decide to distribute your .exe to other people, you'll have to distribute those .dlls with it. In general, you can use ntldd or a similar tool to figure out which .dlls your program depends on.

HolyBlackCat
  • 78,603
  • 9
  • 131
  • 207
  • Hi @HolyBlackCat, I have my compiler's ```bin``` to ```PATH``` already but am still having this problem. Interestingly, though, I do not see ```libwinpthreads... .dll``` in my compiler's bin directory. Could this be what's causing the problem? – Andrew Jun 30 '20 at 14:49
  • @Andrew If there's no `libwinpthreads`, then you don't need it; the specific dlls that your programs use by default depend on the MinGW distribution. There's a possibility that there's some stray incompatible `libgcc_s_dw2-1.dll` either in `C:\Windows`/`C:\Windows\System32` (in that case delete it, it shouldn't be there), or in one of the directories in the `PATH` (in that case remove the offending dir from `PATH`). Or you can copy the dlls instead, as I said. – HolyBlackCat Jun 30 '20 at 14:53