Program can't find libgcc_s_dw2-1.dll

Greg Treleaven picture Greg Treleaven · Feb 13, 2011 · Viewed 69.4k times · Source

Possible Duplicate:
The program can't start because libgcc_s_dw2-1.dll is missing

I'm using Code::Blocks and MinGW 4.4 (I think) compiler to create a C++ project. I get this system error if I run it from its directory, but not from within Code::Blocks.

The program can't start because libgcc_s_dw2-1.dll is missing from your computer.  Try reinstalling the program to fix this problem.

In this post hardmath said to add -static-libgcc to the compiler flags, linking to the dll statically. When I tried this the error still occurred. I could get it to work by adding the MinGW bin directory to my computer's Path variable, but I plan on distributing my program across the internet.

The issue only appeared after updating to the latest G++ compiler. What's the reason for this solution working for everyone else apart from me?

Answer

rubenvb picture rubenvb · Feb 13, 2011

The link commandline argument -static-libgcc should work. Another variant you could try is plain -static.

If you don't want to worry about this, and still want to redistribute your binary, just copy the relevant dll from MinGW's bin directory and place it alongside your executable. This is common practice and works as advertised.