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 in a static library
Forum Updated to NodeBB v4.3 + New Features

[Solved] Linking in a static library

Scheduled Pinned Locked Moved General and Desktop
13 Posts 3 Posters 32.4k Views 2 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.
  • A Offline
    A Offline
    andre
    wrote on last edited by
    #4

    Hmmm... weird. It does contain Widgets_dll in several places. Does that mean it was build wrong?

    Adding -static to the LIBS variable did not help. Or did I misunderstand your second solution?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #5

      [quote author="franku" date="1345213035"]Other ideas, for the link-section try to use this:

      @
      CONFIG( Debug ) {
      LIBS += -shared -L../Libraries/Widgets/debug -lWidgets
      PRE_TARGETDEPS += ../Libraries/Widgets/debug/libWidgets.a
      } else {
      @[/quote]

      I don't understand this. I don't want a shared library, but a static one.

      1 Reply Last reply
      0
      • F Offline
        F Offline
        franku
        wrote on last edited by
        #6

        Ok. If the libwidgets.a lib was built as static lib, then it should not contain references to any dll (I looked for it in some static lib i have for sure and there wasn't). If the -static solution does not static link then in my opinion the build of libwidgets.a went wrong. I do not know yet where or when static and dll libs are used in common.

        However, the order of -static and -lwidgets is important. You may have read in the linked comment above. But in my opinion, maybe I am false, the lib is built wrong.

        This, Jen, is the internet.

        1 Reply Last reply
        0
        • F Offline
          F Offline
          franku
          wrote on last edited by
          #7

          Sorry, this was a typo. I ment -static

          This, Jen, is the internet.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on last edited by
            #8

            Thank you for your help so far.

            I think so you are right something goes wrong in the build, but I for the life of me can't figure out what it might me. I have pasted my "build output":http://pastebin.com/cmxjEV42 online. While inspecting the contents of the CONFIG variable, I did find a "shared" there. The documentation lists "dll" as the keyword that triggers building a shared library, but I tried removing it explicitly anyway. That did not help.

            I had already tried putting the -static in the LIBS (before the lib itself), without result.

            Other suggestions are welcome.

            1 Reply Last reply
            0
            • F Offline
              F Offline
              franku
              wrote on last edited by
              #9

              Ok, I will have a look in the build process. Maybe I find out what happens.
              rgds, .. frank

              This, Jen, is the internet.

              1 Reply Last reply
              0
              • F Offline
                F Offline
                franku
                wrote on last edited by
                #10

                Do you have the output for your application being lonked, too?

                Uups, linked. With icecream in one hand.

                This, Jen, is the internet.

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  andre
                  wrote on last edited by
                  #11

                  Sorry for the absense.

                  I managed to link properly! I noticed from the output that the ar tool was used, and that gave me a good feeling. I deleted the Makefiles and all object files from the libary, and the makefiles and produced binary from the application itself. I then build the library again, and no more .dll strings appeared in the result. Then, I build and linked the application, and it just worked.

                  It seems that, even after cleaning, manually running qmake and doing a complete rebuild, I still had some stale stuff that messed up my build.

                  Thanks for your help!

                  1 Reply Last reply
                  0
                  • F Offline
                    F Offline
                    franku
                    wrote on last edited by
                    #12

                    Glad having helped to [solve]
                    :-)

                    This, Jen, is the internet.

                    1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      kumararajas
                      wrote on last edited by
                      #13

                      Hi Andre,

                      I am facing the similar problem.

                      I am unable to link my static library to my application.

                      My application is unable to see the functions inside the library.

                      I get 'undefined reference to' when I access the function.

                      Any thoughts on this?

                      Thanks,
                      Kumar

                      --Kumar

                      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