没有找到mingwm10.dll的解决办法和mingwm10.dll的作用

今天刚刚装了Qt,并运行了Qt的一个简单的example,然后运行了生成在/debug 文件夹下的 *.exe 文件,但双击执行就提示“没有找到mingwm10.dll,因此这个程序未能启动。重新安装应用程序可能会修复此问题。” 这个问题可能是环境变量没设置好,可以通过:我的电脑->属性->高级->环境变量来修改PATH,这样能永久修改PATH。现在我把"C:/Qt/2009.04/mingw/bin;C:/Qt/2009.04/qt/bin"加入到PATH后,可以运行了。

下面来看看mingwm10.dll的作用:

MinGW的全称是Minimalistic GNU for Windows,它提供了基于GNU GCC 和其他相关程序( make、autoconf 等等)构造Win32 程序所必需的头文件和库。也许你首先会想到Cygwin。两者都是可以将Unix 下程序在Win32下编译运行的办法。但所不同的是,Cygwin中是将完整的POSIX 系统调用映射到本地API,使用一个模拟POSIX 调用的dll。因此在实际执行时的效率比不上本地编译代码。另外一点:Cygwin的License 是GPL,也就是说你在Cygwin上平台的代码必须开放。(这个是很难让人接受的,仅仅因为移植代码就要开放源码)

而MinGW 与Cygwin的上述两点恰好相反,它将代码编译成Win32 本地代码,使用msvcrt.dll的C运行时库。而且MinGW的其他运行库不以GPL License保护,这也意味着你使用MinGW编译的代码不必公开源码。msvcrt.dll本身是随Win32平台发行的,因此这是一个完全免费的环境。

有人会问:有Visual C++、Borland C++ 等等,为什么还要用MinGW ?第一、它们不是免费的;第二、移植Unix下的C/C++程序将十分痛苦。

目前,开源社区中Unix下许许多多著名的库和程序都有了MinGW的版本(因为移植方便)。同时Win32本地 API 和其他一些库,比如DirectX 7/8/9,OpenGL都被移植到了MinGW 下,它是理想的跨平台解决方案。

但经使用发现mingw编译的程序有的还需要mingwm10.dll这个dll。

经搜索:mingwm10.dll是mingw的一个动态链接库,但不是C运行时库.

Even when using VC++ you have to ship the C runtimes, unless you use VC++ 6 which has the same C runtime as shipped with Windows already.

Volker

NOT true, because "-mthreads" is just needed for thread-safe exception handling. Since Qt DOES NOT use exceptions at all, you can safly remove this flag on a MinGW32-System.

有-mthreads链接选项则需要这个dll。怎样静态链接进去,还没有发现。

If you wish to remove the dependency on mingwm10.dll as well, here are the steps I followed.
Note: there is some discussion around the forums as to whether this is a valid solution.
It seems to work for me so far.

Edit c:/qt/qt4.2.3/mkspecs/win32-g++/qmake.conf and remove all occurrences of "-mthreads".
Recompile Qt as above. Compile your project and the dependency on mingwm10.dll will be no longer.

I created a MT application with u++, and run it withouth mingw10.dll successfully.
This is not supposed to be possible. Multithreaded applications should be built with the "-mthreads" option given to the compiler, which will trigger dynamic linking to mingw10.dll. It is promissed that a future version of MinGW will remove this severe inconvenience.
There are long discussions about this topic on the Qt forum.

That -mthreads is needed, because it makes the compiler generate thread-safe versions of some codes.
It links with mingwm10.dll as the dll framework provide the only documented way a certain cleanup code
could be triggered after each thread terminates. (VC++ uses an undocumented way) So I can no longer hope that you somehow miraculosly removed the dependency on mingwm10.dll.

Ok, for the benefit of Anonymous, this is how you get rid of mingwm10.dll.

Edit the file $QTDIR/mkspecs/win32-g++/qmake.conf and remove all instances of -mthreads.
Then recompile your app. The mingwm10.dll is no longer a dependancy


Disclaimer: No-one seems to be entirely sure what that DLL is there for.
The best explanation I've seen is that it has something to do with propagating exceptions in multithreaded programs. However, Qt doesn't use exceptions, so unless you use them yourself, it shouldn't be a problem. I haven't had any problems with the DLL removed, and many others have
reported smooth sailing as well. However, this could create problems if you use exceptions and
threads in your program.

As far as I know mingw-compiled multithreaded applicaions should always be dynamically linked to mingwm10.dll, so this file should be available on computers running the application. It seems that U++ somehow removes this nasty limitation. How is that possible?

Technorati : gnu, mingw
Del.icio.us : gnu, mingw
Ice Rocket : gnu, mingw
Flickr : gnu, mingw
Zooomr : gnu, mingw
Buzznet : gnu, mingw
Riya : gnu, mingw
43 Things : gnu, mingw

“没有找到mingwm10.dll,因此这个程序未能启动。重新安装应用程序可能会修复此问题。”(windows XP) 1》/debug 文件夹下的 *.exe 文件一双击执行就提示“没有找到mingwm10.dll,因此这个程序未能启动。重新安装应用程序可能会修复此问题。” 这个问题可能是环境变量没设置好,可以通过 我的电脑->属性->高级->环境变量来修改 PATH,这样能永久修改PATH. 现在我把"F:/ProgramFiles/Qt/2009.01/mingw/bin;F:/ProgramFiles/Qt/2009.01/qt/bin"加入到PATH后,可以运行了。 2》用 Qt designer 设计好 ***.ui 之后, 要得到所需要的 ***.h/***.cpp 文件时, 需要用到 uic.exe。一开始以为只要把uic.exe拷到*.ui同一文件夹下就可以了,当执行 uic ***.ui -o ***.h 时,提示“没有找到mingwm10.dll,因此这个程序未能启动。重新安装应用程序可能会修复此问题。” 之后试了下把 ***.ui 拷到 uic.exe 的文件夹下(F:/ProgramFiles/Qt/2009.01/qt/bin),用命令行 cmd 切换到该目录下,再在执行 uic ***.ui -o ***.h, 可以得到相应的 ***.h 文件了。另外,在Qt designer中好像可以直接通过工具栏 "窗体-->查看代码" 来获得 ***.h 的代码, copy出来就OK了. 有一点需要注意:qt4之前的版本是需要 uic ***.ui -o ***.h / uic ***.ui -o ***.cpp 来得到 ***.h/***.cpp的,而在 qt4 中之需要得到 ***.h. 关于这一点在另一篇文章 "Qt4与Qt3的主要不同" 中有比较详细的说明. 既然要更新控件,那么你就需要使用QDesigner工具来重新画界面了,OK,重画只是纯体力劳动,好说。界面画好后,使用uic来根据界面生成代码文件,QT3的uic可以自动生成.h和.cpp文件,假设你在制作一个名叫TestDialog的对话框,那么 QT3的uic生成的文件则是TestDialog.h和TestDialog.cpp,所有的界面初始化工作都在cpp文件中执行,之后程序的逻辑代码也将加入这个文件,那么对于一个已经完成逻辑功能的对话框来说,如果要修改界面布局,你就不得不重新用uic生成.h和.cpp文件,然后将其中界面相关的代码复制到你已经修改的文件中,此时决不能直接用uic直接生成到修改过的文件上,因为那样你的代码将全部被冲掉。这一点上,QT4进步了,因为QT4中推荐的方法是,使用uic根据界面文件生成一个h文件,以前面的TestDialog为例,生成的文件叫做ui_TestDialog.h,其中会实现一个名为Ui_TestDialog的类,包含了界面所有控件的加载功能,而程序的逻辑功能依然使用TestDialog.h,和 TestDialog.cpp这两个功能,并在TestDialog.h中用多重继承的方法,从刚才的Ui_TestDialog类来继承出实际的 TestDialog类,在TestDialog的构造函数中,只需要使用Ui_TestDialog::setupUi()方法,就可以构建出整个界面,并且由于是从Ui_TestDialog继承来的,在逻辑代码中也可以方便的访问所有控件。从这一点来说,QT4的方法是个巨大的进步,因为ui_xxx.h中不再包含任何用户自己写的代码了,此时你想更改界面布局的话,只需要用QDesigner修改界面,再用uic生成ui_xxx.h文件,直接替换原文件就可以了。当然,QT的ui_xxx.h文件还有其它的使用方法,不一定要使用多重继承的方法,在这里我只是介绍了我认为最方便的方法。另外,如果你所设计的界面比较复杂,需要将某部分界面独立在其它Widget中设计和写逻辑代码,那么最上层的Dialog的ui_xxx.h文件还是需要手动修改的,不过相对于QT3,这样的修改还是非常简单的。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值