0
votes

I am trying to build a standalone Qt app without any DLLs needed. I recompiled Qt 5.4.1 statically. When I compile and run an application, it doesn't require any Qt DLLs, but it requires libgcc_s_dw2-1.dll instead. I have also edited my mkspecs before configuring and building Qt, I edited these values:

QMAKE_CFLAGS            = -pipe -fno-keep-inline-dllexport -static -static-libgcc
QMAKE_CXXFLAGS          = -pipe -fno-keep-inline-dllexport -static -static-libgcc -static-libstdc++

(added -static -static-libstdc++ and -static-libgcc)

I also added a QMAKESPECS environment variable. When I build something using Qt, I can always see this options in the output, so I am sure that the mkspecs are applying. When I build a non-Qt program with these options (-static -static-libgcc -static-libstdc++), it doesn't need any DLLs when I run it.

Can somebody help me? I use Qt 5.4.1 and MinGW-w64 4.9.2

1
These options should prevent the libgcc_s_dw2-1.dll thus it is most likely that either your main executable or some external dll did not pick up this flag. Can you use a tool like dependency walker to see which dll/executable exactly depends on this dll?Rudolfs Bundulis
@RudolfsBundulis I tried to view it in Dependency Walker now, but it seems that only the program itself depends on libgcc, although I used the mentioned arguments when compiling.. And it does't depend on any other library than Qt. The program I am compiling is very simple, it is only a few lines of code. I don't even use any standard libraries in the program (only Qt does)amethystAnt
I'm not sure what you meant by libgcc - the exact dll you mentioned or something else? You should also look at the Qt dll's with dependency walker and possibly Qt plugins if you are using any to find which file exactly loads the mentioned dll. When you compile the app itself do you pass the static libraries as linker flags or no?Rudolfs Bundulis

1 Answers

0
votes

I solved my problem now. The problem was that although I edited the variable QMAKE_CXXFLAGS, it was still linking the standard libraries dynamically when linking the application itself, because it doesn't use this variable in the final step of the compilation. I only edited the mkspecs again and added the -static option to the variable QMAKE_LIBS and it works now, I have a standalone Qt application.