Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1919469
  • 博文数量: 496
  • 博客积分: 12043
  • 博客等级: 上将
  • 技术积分: 4778
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-27 14:26
文章分类

全部博文(496)

文章存档

2014年(8)

2013年(4)

2012年(181)

2011年(303)

2010年(3)

分类: C/C++

2011-04-27 14:26:56

今天刚刚装了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 : ,
Del.icio.us : ,
Ice Rocket : ,
Flickr : ,
Zooomr : ,
Buzznet : ,
Riya : ,
43 Things : ,

阅读(837) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~