1

I have a Windows 7 64bit system with the latest MinGW (32bit) installed along with the Qt 5.5 SDK (again 32bit) which also ships with its own MinGW. Due to the fact that I'm not the only one using the system I can't remove the standalone MinGW.

My project is using qmake and is a plain C project (not C++). Everything builds fine but when I try to execute my binary in the command line I get that the application was unable to start due to a missing libgcc_s_dw2-1.dll on the system.

After looking into the issue I found that both the standalone MinGW and the one shipped alongside the Qt SDK have the mentioned DLL.

  • Standalone MinGW - libgcc_s_dw2-1.dll is located inside the bin subdirectory of the MinGW installation where the binaries are located (gcc, g++, gdb etc.)
  • Qt MinGW - libgcc_s_dw2-1.dll is located inside C:\Qt\Tools\mingw492_32\i686-w64-mingw32\lib subdirectory while the MinGW components' binaries are inside C:\Qt\Tools\mingw492_32\i686-w64-mingw32\bin.

I would like to know how to properly set my PATH variable so that:

  • The application starts properly
  • No conflicts with the standalone MinGW installation occur

Just a side-note: I've already checked other posts here on SO but was unable to find a solution (perhaps I've missed it). I have also tried LIBS += -static but the result is the same.

rbaleksandar
  • 8,713
  • 7
  • 76
  • 161

1 Answers1

0

You just need to copy this dll with your executable, i.e.:

cp <path-to-qt-install-dir>\qt5.7.0\5.7\mingw53_32\bin\libgcc_s_dw2-1.dll <path-to-dest-dir>

You mat find that you have other dependencies, to see which other deps you have you can use: ldd <your-executable>. You only need to copy the qt specific dlls you can see these by:

ldd <executable> | grep -i qt

note

You can statically link it with: linker commands like -static-libgcc or -static, but I think you start to hit LGPL issues and also you may need to statically compile qt from source - can't recall for this particular file.

note2

Sorry ldd is for linux, just realized you have windows, in which case you can use one or both of:

  • dependency walker: from here

  • <path-to-qt-bin-folder>\windeployqt.exe <path-to-your-executable>

I have mixed results with windeployqt, but if you have any plugins its quiet good for getting that part sorted.

code_fodder
  • 15,263
  • 17
  • 90
  • 167
  • 1
    Linking statically with libgcc and libstdc++ is not the way to go here: Qt links to the DLLs anyway, so you'll still have the dependency, and on top of that, you now have to compiler runtimes and C++ standard libraries in your application, messing with their possible global state. – rubenvb Jul 06 '16 at 07:50
  • 1
    Also note that the MSYS2 environment comes with a Windows `ldd` which is mighty handy. – rubenvb Jul 06 '16 at 07:51
  • @rubenvb - Yeah, I have gone away from static linking of late... regarding the ldd on windows (cool) do you have a link for that? (where it is) - I find the linux tools far better... – code_fodder Jul 06 '16 at 07:54
  • 1
    You can find MSYS2 [here](http://msys2.github.io/). Note that it is essentially a bash shell with the `pacman` package manager (linked to a repository with a huge amount of packages) based off of Cygwin. All `mingw-w4-*` packages are native, so anything you compile/link with those is native non-Cygwin code. – rubenvb Jul 06 '16 at 08:06
  • @rubenvb - sweet : ) I just could not be bothered with full cygwin this time around :o – code_fodder Jul 06 '16 at 08:11