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

http://stackoverflow.com/questions/4702732/the-program-cant-start-because-libgcc-s-dw2-1-dll-is-missing

Question:

I have created a simple program in C++ with Code::Block.

If I run it from Code::Block, it works correctly; but if I run it by doubleclicking on the executable file, a window pops up with this message:
    The program can't start because libgcc_s_dw2-1.dll is missing from your computer.
    Try reinstalling the program to fix this problem.
So, what is the problem? What do I have to do to fix it?

Answer:

I believe this is a MinGW/gcc compiler issue, rather than a Microsoft Visual Studio setup.

The libgcc_s_dw2-1.dll should be in the compiler's bin directory. You can add this directory to your PATH environment variable for runtime linking, or you can avoid the problem by adding "-static-libgcc -static-libstdc++" to your compiler flags.

If you plan to distribute the executable, the latter probably makes the most sense. If you only plan to run it on your own machine, the changing the PATH environment variable is an attractive option (keeps down the size of the executable).

Updated:
Based on feedback from Greg Treleaven (see comments below), I'm adding links to:

[Screenshot of Code::Blocks "Project build options"] http://www.codeblocks.org/docs/main_codeblocks_en3.html#x3-1060003.11
[GNU gcc link options] http://gcc.gnu.org/onlinedocs/gcc/Link-Options.html#Link-Options

The latter discussion includes -static-libgcc and -static-libstdc++ linker options.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值