Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Remove dependency to LIBWINPTHREAD-1.DLL
QtWS25 Last Chance

Remove dependency to LIBWINPTHREAD-1.DLL

Scheduled Pinned Locked Moved Solved General and Desktop
13 Posts 4 Posters 13.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    outsider
    wrote on 12 Jan 2016, 23:34 last edited by
    #1

    Hi,
    I built a desktop application for Windows under a commercial license but can't remove dependency to LIBWINPTHREAD-1.DLL

    I first built a static Qt 5.4.2 .
    Then I removed dependency to LIBGCC_S_DW2-1.DLL and LIBSTDC++-6.DLL by adding in my .PRO file:
    CONFIG += static
    QMAKE_LFLAGS += -static-libgcc -static-libstdc++

    Now I'm only left with the .EXE and LIBWINPTHREAD-1.DLL (the app runs OK with these two).
    I tried replacing the previous line with:
    QMAKE_LFLAGS += -static-libgcc -static-libstdc++ -Wl,-Bstatic -lwinpthread
    and rebuild, but that still doesn't remove the dependency.

    Any ideas?
    Thanks

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 13 Jan 2016, 10:35 last edited by mrjj
      #2

      Hi and welcome
      this is with mingw compiler ?

      O 1 Reply Last reply 13 Jan 2016, 11:36
      0
      • M mrjj
        13 Jan 2016, 10:35

        Hi and welcome
        this is with mingw compiler ?

        O Offline
        O Offline
        outsider
        wrote on 13 Jan 2016, 11:36 last edited by
        #3

        @mrjj Yes it is !

        M 1 Reply Last reply 13 Jan 2016, 11:39
        0
        • O outsider
          13 Jan 2016, 11:36

          @mrjj Yes it is !

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 13 Jan 2016, 11:39 last edited by
          #4

          @outsider
          hi
          I assume you saw this
          http://stackoverflow.com/questions/13768515/how-to-do-static-linking-of-libwinpthread-1-dll-in-mingw
          did u try with -lstdc++ as it seems to work for him
          "
          -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic
          Notice the -lstdc++ before -lpthread. It worked for me.
          "

          1 Reply Last reply
          2
          • O Offline
            O Offline
            outsider
            wrote on 13 Jan 2016, 11:49 last edited by
            #5

            I did try that but it didn't work for me.

            M 1 Reply Last reply 13 Jan 2016, 11:59
            0
            • O outsider
              13 Jan 2016, 11:49

              I did try that but it didn't work for me.

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 13 Jan 2016, 11:59 last edited by
              #6

              @outsider @outsider
              Ok. damn :)
              Googling it a bit it seems
              that default its not possible with the mingw version that comes with Qt.
              At least I could not get it to work either.

              Is it 64 bit?

              Since you have commercial support, you could call them and ask?

              O 1 Reply Last reply 13 Jan 2016, 12:12
              0
              • M mrjj
                13 Jan 2016, 11:59

                @outsider @outsider
                Ok. damn :)
                Googling it a bit it seems
                that default its not possible with the mingw version that comes with Qt.
                At least I could not get it to work either.

                Is it 64 bit?

                Since you have commercial support, you could call them and ask?

                O Offline
                O Offline
                outsider
                wrote on 13 Jan 2016, 12:12 last edited by
                #7

                @mrjj I am rebuilding Qt now, making sure that the same mingw was used for building static Qt and static app... I'll get back with an answer after that and will try to call support too. Thanks!

                M 1 Reply Last reply 13 Jan 2016, 12:13
                0
                • O outsider
                  13 Jan 2016, 12:12

                  @mrjj I am rebuilding Qt now, making sure that the same mingw was used for building static Qt and static app... I'll get back with an answer after that and will try to call support too. Thanks!

                  M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 13 Jan 2016, 12:13 last edited by
                  #8

                  @outsider
                  Ok sorry I couldn't be of more help
                  and good luck :)

                  O 1 Reply Last reply 13 Jan 2016, 21:22
                  0
                  • M mrjj
                    13 Jan 2016, 12:13

                    @outsider
                    Ok sorry I couldn't be of more help
                    and good luck :)

                    O Offline
                    O Offline
                    outsider
                    wrote on 13 Jan 2016, 21:22 last edited by outsider
                    #9

                    @mrjj I got it to work:

                    • I build my project normally from Qt IDE with :
                      CONFIG += static
                      QMAKE_LFLAGS += -static-libgcc -static-libstdc++

                    • This creates a binary name.exe still dependent on libwinpthread-1.dll
                      (IMPORTANT: If you test it on the same computer, it might work, because your environment PATH contains the DLL, but it won't work on another computer.)

                    • Now I checked the last g++ command in Compile Output (bottom line in Qt IDE). This is what I got (you might get something different depending on the project options - JUST COPY THE COMMAND YOU HAVE):

                    g++ -static-libgcc -static-libstdc++ -Wl,-s -Wl,-subsystem,windows -mthreads -o release\name.exe object_script.name.Release -lmingw32 -LC:/Qt/542static/qtbase/lib -lqtmain -lQt5OpenGL -lQt5Widgets -LC:/Qt/542static/qtbase/plugins/platforms -lqwindows -lwinspool -lshlwapi -lQt5PlatformSupport -LC:/Qt/542static/qtbase/plugins/imageformats -lqdds -lqicns -lqico -lqjp2 -lqmng -lqtga -lqtiff -lqwbmp -lqwebp -lQt5Gui -lcomdlg32 -loleaut32 -limm32 -lwinmm -lglu32 -lopengl32 -lgdi32 -lqtharfbuzzng -lQt5Core -lole32 -luuid -lws2_32 -ladvapi32 -lshell32 -luser32 -lkernel32 -lmpr -lz

                    • I launched the command prompt : Start>Run>cmd.exe

                    • Changed the directory to build-name-542_static-Release (where the Makefile is)

                    • I copied the final line into the command prompt and AT THE END I ADDED the static libraries directly by name:
                      -l:libwinpthread.a

                    • So my command was now :

                    g++ -static-libgcc -static-libstdc++ -Wl,-s -Wl,-subsystem,windows -mthreads -o release\name.exe object_script.name.Release -lmingw32 -LC:/Qt/542static/qtbase/lib -lqtmain -lQt5OpenGL -lQt5Widgets -LC:/Qt/542static/qtbase/plugins/platforms -lqwindows -lwinspool -lshlwapi -lQt5PlatformSupport -LC:/Qt/542static/qtbase/plugins/imageformats -lqdds -lqicns -lqico -lqjp2 -lqmng -lqtga -lqtiff -lqwbmp -lqwebp -lQt5Gui -lcomdlg32 -loleaut32 -limm32 -lwinmm -lglu32 -lopengl32 -lgdi32 -lqtharfbuzzng -lQt5Core -lole32 -luuid -lws2_32 -ladvapi32 -lshell32 -luser32 -lkernel32 -lmpr -lz -l:libwinpthread.a

                    • You will notice the name.exe getting a bit bigger and things are ok now. I tested it on another computer without Qt or any programming environment and it worked.

                    I also tried to do it this way QMAKE_LFLAGS += -static-libgcc -static-libstdc++ -l:libwinpthread.a
                    but that doesn't work, I think it's because the .a is not added at the end in the g++ command line
                    So yeah it's a bit complicated but it can be done.
                    If anyone finds a simpler alternative feel free to let us know.

                    1 Reply Last reply
                    3
                    • M Offline
                      M Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on 13 Jan 2016, 21:28 last edited by
                      #10

                      Congrats and thank you for posting solution.

                      O 1 Reply Last reply 13 Jan 2016, 21:37
                      0
                      • M mrjj
                        13 Jan 2016, 21:28

                        Congrats and thank you for posting solution.

                        O Offline
                        O Offline
                        outsider
                        wrote on 13 Jan 2016, 21:37 last edited by
                        #11

                        @mrjj Thanks :)

                        Apparently QMAKE_LFLAGS lacks the option to add something at the end in that last link command.
                        On various sites people kept saying that the static libraries should be added at the end - but I don't know if it can be done directly from the .pro file.

                        T 1 Reply Last reply 23 Jun 2018, 09:33
                        0
                        • O outsider
                          13 Jan 2016, 21:37

                          @mrjj Thanks :)

                          Apparently QMAKE_LFLAGS lacks the option to add something at the end in that last link command.
                          On various sites people kept saying that the static libraries should be added at the end - but I don't know if it can be done directly from the .pro file.

                          T Offline
                          T Offline
                          tixiv
                          wrote on 23 Jun 2018, 09:33 last edited by
                          #12

                          @outsider Hi,
                          I had the same problem (imports from libwinpthread-1.dll in my static Qt application), and I was able to solve it with the following line in the qmake config of qt creator:

                          CONFIG+=static "QMAKE_LFLAGS+=-static -static-libgcc -static-libstdc++ -lstdc++" DEFINES+=STATIC

                          The important part seems to be the "-static" switch before "-lstdc++"

                          1 Reply Last reply
                          5
                          • D Offline
                            D Offline
                            Dianne476
                            Banned
                            wrote on 29 Aug 2018, 05:01 last edited by
                            #13
                            This post is deleted!
                            1 Reply Last reply
                            -1

                            • Login

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • Users
                            • Groups
                            • Search
                            • Get Qt Extensions
                            • Unsolved