问题描述
我用 Code::Blocks 用 C++ 创建了一个简单的程序.
如果我从 Code::Blocks 运行它,它可以正常工作;但是如果我通过双击可执行文件来运行它,则会弹出一个带有此消息的窗口:
<块引用>程序无法启动,因为您的计算机缺少 libgcc_s_dw2-1.dll.
尝试重新安装程序以解决此问题.
那么,问题是什么?我该怎么做才能修复它?
我认为这是 MinGW/gcc 编译器问题,而不是 Microsoft Visual Studio 设置.
libgcc_s_dw2-1.dll
应该在编译器的 bin 目录中.您可以将此目录添加到您的 PATH 环境变量以进行运行时链接,或者您可以通过在编译器标志中添加-static-libgcc -static-libstdc++"来避免该问题.
如果您打算分发可执行文件,则后者可能最有意义.如果您只打算在自己的机器上运行它,那么更改 PATH 环境变量是一个有吸引力的选择(减少可执行文件的大小).
更新:
根据 Greg Treleaven 的反馈(见下面的评论),我添加了以下链接:
[Code::Blocks项目构建选项"的屏幕截图]
[GNU gcc 链接选项]>
后面的讨论包括 -static-libgcc
和 -static-libstdc++
链接器选项.
I have created a simple program in C++ with Code::Blocks.
If I run it from Code::Blocks, 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?
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"]
[GNU gcc link options]
The latter discussion includes -static-libgcc
and -static-libstdc++
linker options.
这篇关于程序无法启动,因为缺少 libgcc_s_dw2-1.dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!