且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

MinGW 编译的程序在 64 位 Windows 上崩溃

更新时间:2023-09-29 17:41:40

当我试图在另一台没有安装 MinGW 的计算机上运行 EXE 时,它抱怨:

When I tried to run the EXE on another computer that didn't have MinGW intalled, it complained:

程序无法启动,因为您缺少 libgcc_s_dw2-1.dll计算机.尝试重新安装程序以解决此问题.

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

谷歌搜索该错误使我想到了 SO 问题 程序无法启动,因为缺少libgcc_s_dw2-1.dll

Googling that error led me to the SO question The program can't start because libgcc_s_dw2-1.dll is missing

来自答案:

libgcc_s_dw2-1.dll 应该在编译器的 bin 目录中.您可以将此目录添加到 PATH 环境变量中运行时链接,或者您可以通过添加来避免该问题-static-libgcc -static-libstdc++"到你的编译器标志.

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.

所以我添加了标志,结果程序在两个系统上都能正常运行.我不确定为什么需要这些标志才能在我的开发系统上正常工作,因为 MinGW bin 目录位于 PATH 中.任何人都可以提供解释吗?我应该创建一个单独的问题吗?

So I added the flags, and the resulting program ran normally on both systems. I'm not sure why these flags were required for it to work properly on my dev system, because the MinGW bin directory is in the PATH. Can anyone provide an explinantion? Should I create a seperate question?