分发一个用MinGW g++编译的程序
假设我使用 MinGW 64(g++ 编译器)创建并编译了一个简单的程序.在我的计算机上运行这个程序并在 Process Explorer 中查找我发现的程序正在使用的 DLL 文件(以及许多其他文件):
Let's say I have created and compiled a simple program using the MinGW 64 (g++ compiler). Running this program on my computer and looking in Process Explorer for what DLL files the program is using I find (among many others):
libgcc_s_seh-1.dll
libstdc++6.dll
libwinpthread-1.dll
这些是唯一位于我的 MinGW 安装文件夹下的.使用的其余 DLL 文件位于 C:Windows
下.
These are the only ones that reside under my MinGW installation folder. The rest of the DLL files used reside under C:Windows
.
问题 1:
MinGW DLL 文件是 MinGW C++ 运行时库(可以这么说)吗?它们的用途是否与 msvcrXXX.dll(XXX = Microsoft 运行时库的版本)等用途相同.
Are the MinGW DLL files the MinGW C++ runtime libraries (so to speak)? Do they serve the same purpose as for example msvcrXXX.dll (XXX = version of Microsoft runtime library).
问题 2:
如果我想在没有安装 MinGW 的另一台计算机上运行该应用程序,是否足以包含上面列出的那些 DLL 文件(即将它们与我的可执行文件放在同一文件夹中)让它在另一台计算机上运行计算机(我们假设另一台计算机也是 64 位 Windows 计算机).如果是,这是否意味着我们基本上将 MinGW C++ 运行时与我们的可执行文件一起发布.如果不是,为什么?
If I want to run the application on a different computer which does not have MinGW installed, is it sufficient to include those DLL files listed above (i.e. placing them in the same folder as my executable) to have it run on the other computer (we assume the other computer is also a 64-bit Windows machine). If yes, does this mean we basically ship the MinGW C++ runtime with our executable. If no, why?
推荐答案
libstdc++6.dll 是 C++ 标准库,就像你说的.
libstdc++6.dll is the C++ standard library, like you said.
libwinpthread-1.dll 用于 C++11 线程支持.MinGW-W64 有两种可能的线程变体:要么使用本地 Windows 函数,如 CreateThread,但 C++11 的东西如 std::thread 将不可用;或包含此库并使用 C++11 类(也).
请注意,要切换线程模型,您需要重新安装 MinGW.仅删除 DLL 而不使用 C++11 的东西是行不通的,但您当前的安装仍然需要 DLL.
libwinpthread-1.dll is for C++11 threading support. MinGW-W64 has two possible thread variants: Either use the native Windows functions like CreateThread, but C++11 stuff like std::thread won′t be available then; or include this library and use the C++11 classes (too).
Note that to switch the thread model, you′ll need to reinstall MinGW. Just removing the DLL and not using the C++11 stuff won′t work, the DLL will be required nonetheless with your current install.
libgcc_s_seh-1.dll 是关于 C++ 异常处理的东西.
libgcc_s_seh-1.dll is something about C++ exception handling.
是的,提供 DLL 也应该足够了
(或使用静态链接并仅提供您的程序文件).
Yes, it should be sufficient to deliver the DLLs too
(or use static linking and deliver only your program file).
相关文章