运行.exe时出错 [英] Error running .exe

查看:188
本文介绍了运行.exe时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚用cing编写了一个相当长的应用程序,我用mingw来给几个朋友试试一下。当他们执行.exe文件时,会出现一个错误:

I just went through writing a fairly lengthly application in c++ using mingw and I went to give it to a few friends to try it out. When they went to execute the .exe file it came up with an error that says:


程序无法启动,因为libgcc_s_dw2-1您的计算机中缺少.dll。尝试重新安装程序来解决这个问题

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

调试版本发生此错误。编译与发行版本出现相同的错误,除了libgcc_s_dw2被替换为libstdc ++ - 6。

This error occurs with the debug version. Compiling with the release version comes up with the same error except "libgcc_s_dw2" is replaced with "libstdc++-6".

我能够解决这个问题包括。 dll的.exe,但我宁愿它是独立的,当我决定发布给更多的一般观众。

I was able to fix this issue by including the .dll's with the .exe but I would rather it be standalone for when I decide to release it to more of a general audience.

我发现这个问题很多,但所有人都说要向链接器选项添加 -static-libstdc ++

I have found this question asked a lot but all of them say to add -static-libstdc++ to the linker options.

我正在使用CodeBlocks,并转到构建选项并将其放在与MinGW连接的同一位置。这没有办法,所以我尝试了附加选项旁边的另一个选项,但是没有起作用。

I am using CodeBlocks and went to build options and put it in the same location I linked MinGW with. This didn't work, so I tried the other box next to it for additional options but that didn't work either.

我知道这可能是一件简单的事情,我很遗憾,但我无法想到任何地方。

I know it's probably a simple thing that I'm missing but I can't think of anywhere to put it.

我感谢任何帮助,并提前感谢。

I appreciate any help and thanks in advance.

推荐答案

我添加了选项 -static-libgcc -static-libstdc ++ 到链接器设置,如 here (由空格分隔)所示,它的工作原理对于我来说,

I added the options -static-libgcc and -static-libstdc++ to the Linker settings as shown here (separated by a space) and it worked for me.

确保从Build菜单(或使用Ctrl-F11)重建可执行文件,如果您只是在更改后尝试构建,CodeBlocks将不会重建它设置。

Make sure to rebuild your executable from the Build menu (or with Ctrl-F11), CodeBlocks won't rebuild it if you just try to build after changing the settings.

这篇关于运行.exe时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆