Distribute a program compiled with MinGW g++

jensa picture jensa · Jul 16, 2015 · Viewed 8.1k times · Source

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

These are the only ones that reside under my MinGW installation folder. The rest of the DLL files used reside under C:\Windows.

Question 1:

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).

Question 2:

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?

Answer

deviantfan picture deviantfan · Jul 16, 2015

libstdc++6.dll is the C++ standard library, like you said.

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 is something about C++ exception handling.

Yes, it should be sufficient to deliver the DLLs too
(or use static linking and deliver only your program file).