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?
没有评论:
发表评论