4

I know this has been asked before but I can't seem to find an answer.

I just have a little hello world console program basically I wrote in c++ with qt creator. When I try to run the executable I get "The program can't start because libgcc_s_dw2-1.dll is missing from your computer. Try reinstalling to fix this problem."

I don't understand why this dll is even necessary for a little program like this. I tried adding these flags as suggested elsewhere:

QMAKE_CXXFLAGS += -static -static-libgcc -static-libstdc++

and it still happens. Other people have suggested adding the directory whee the dll is located to my path but I'd like to actually give this program to someone else without them needing the dll.

gghuffer
  • 1,133
  • 1
  • 9
  • 15
  • `-static` should be enough, if it still depends on the libgcc dll then use dependency walker to see where the issue is, either the static libgcc lib can't be found when linking so the linker is falling back on the dll, or some other component depends on it instead (which will need to be recompiled with the static lib). – user657267 Oct 15 '15 at 00:11
  • qmake links libgcc by default, no matter how big your application, because this lib contains C++ runtime. – RazrFalcon Oct 15 '15 at 06:09

2 Answers2

3

I know this is an old question, and you probably found a solution that worked for you, but I stumbled upon this after a day spent trying to build a statically linked (standalone) application with Qt 5.9.1/MinGW32-5.3.0-32bit.

After building a static version of Qt, it was finally these dynamically linked libraries that MinGW / GCC pulled in that was still holding me back:

libgcc_s_dw2-1.dll
libwinpthread-1.dll
libstdc++-6.dll
libwinpthread-1.dll

After trying countless combinations of:

QMAKE_CXXFLAGS += [-static-libgcc | -static-libstdc++ | -static -lstdc++ -lpthread] 

and other compiler parameters found in threads similar to this one, what finally worked for me was:

QMAKE_LFLAGS += -static

That is, QMAKE_LFLAGS instead of QMAKE_CXXFLAGS and now my program only relies on a bunch of Windows DLL's. :)

Snorre O.
  • 31
  • 2
0

You need to do the below settings in QT Editor Go to the project tab (on the left) to edit the project's setting.

In the section Run Settings, Under Working directory click on the checkbox the Run in Terminal.

Ulhas
  • 3
  • 2