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. [Solved] Linking statically against some libs

[Solved] Linking statically against some libs

Scheduled Pinned Locked Moved General and Desktop
10 Posts 4 Posters 9.1k Views 1 Watching
  • 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.
  • B Offline
    B Offline
    beedaddy
    wrote on last edited by
    #1

    Hello,

    sorry for this beginner question but I'm somehow stuck...
    I'm playing around with Qt and created a small application which perfectly compiles and runs on Linux. It uses libical and boost. Now I would like to build it on Windows. Installing the libs went smoothly (using MinGW). But now I think QtCreator (or qmake, that is) tries to link dynamically. How can I link to these libs (not Qt!) statically?

    What makes me wonder is that QtCreator thinks that the (static) libs end with .lib, but their suffix is .a. So, I can't add them via the GUI dialog, but did it manually, for example:
    @win32: INCLUDEPATH += $$quote(C:/mylibs/mingw/include)
    win32: LIBS += -L$$quote(C:/mylibs/mingw/lib) -llibical@

    Somewhere I read that CONFIG += static will do the trick, but it doesn't change anything.

    So, maybe you can help me with this.

    Thanks a lot
    Martin

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      welcome to devnet

      The Qt precompiled versions are always for dynamic linking. You would need to compile Qt by yourself for static linking.

      However, beware of the "license issues":http://qt.nokia.com/products/licensing as well.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • B Offline
        B Offline
        beedaddy
        wrote on last edited by
        #3

        Thanks koahnig. I'm aware of the licensing model. So it isn't possible to link some libs (Qt) dynamically and some others statically? I wasn't aware of this linker restriction (haven't done so much with libs).

        But then it would be nice if the build process would copy the dynamic libs into the build-dir so that the .exe can find them (on windows, that is), right?

        1 Reply Last reply
        0
        • U Offline
          U Offline
          unai_i
          wrote on last edited by
          #4

          Hello,
          Linking some libs statically and Qt dynamically is totally possible. The .a file should be ok as long as you compiled it for Windows or you downloaded windows version. I think Qt Creator has nothing to do with your problem but it's more gcc (or more precisely the linker) which handles your libraries while building. CONFIG += static is for compiling your lib statically not the app.
          What messages have you got? Missing references while linking, missing dll when running?

          1 Reply Last reply
          0
          • K Offline
            K Offline
            koahnig
            wrote on last edited by
            #5

            My remark on dynamic distribution was about the Qt libs only. As already asked by unai_i what are your error messages?

            Vote the answer(s) that helped you to solve your issue(s)

            1 Reply Last reply
            0
            • B Offline
              B Offline
              beedaddy
              wrote on last edited by
              #6

              I only got the message, that the linker couldn't find the lib, e.g.:
              @c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/bin/ld.exe: cannot find -llibboost_date_time-mgw47-mt-1_50@

              But the .a files are available. If I compile boost also for dynamic linking (.dll.a, if I understand this correctly), the linker finds the lib but links it dynamically.

              Maybe I just don't know how to tell qmake that I want to link dynamically?

              1 Reply Last reply
              0
              • S Offline
                S Offline
                Sam
                wrote on last edited by
                #7

                May be not much of help but there is a video tutorial "here":http://www.voidrealms.com/viewtutorial.aspx?id=245 that you can check .

                1 Reply Last reply
                0
                • B Offline
                  B Offline
                  beedaddy
                  wrote on last edited by
                  #8

                  Sam, yes, that was it. Thanks a lot! What I had to do is:
                  @win32: LIBS += "C:/mylibs/mingw/lib/llibboost_date_time-mgw47-mt-1_50.a"@

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    Sam
                    wrote on last edited by
                    #9

                    You are welcome,

                    Glad to know that its working :) Kindly Edit the title and add [Solved]

                    1 Reply Last reply
                    0
                    • B Offline
                      B Offline
                      beedaddy
                      wrote on last edited by
                      #10

                      Ok, title is edited. The only problem now is that my current MinGW/GCC version (4.7) doesn't seem to fit with the precompiled Qt binaries (MinGW 4.4). But that's a different thing. This one is solved. :)

                      EDIT: Recompiled Qt 4.8.2 with MinGW GCC 4.7.0 and now everything works.

                      1 Reply Last reply
                      0

                      • Login

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