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. I want to link DLLs not Static Libraries
Qt 6.11 is out! See what's new in the release blog

I want to link DLLs not Static Libraries

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 2.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.
  • Bear35645B Offline
    Bear35645B Offline
    Bear35645
    wrote on last edited by
    #1

    I am currently using Qt with MSVC2013 for the compiler. For some reason it wants to link in static libraries, but I want to link in dlls. What do I need to do to force it to use the dlls instead of the libs?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You don't link to dlls, you always link to lib files. The only thing is that both static libraries and import libraries are using the same extension. So first thing to determine is if you are indeed linking to a static lib or an import lib. A rule of thumb is that import libs are generally small files compare to static libs.

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • Bear35645B Offline
        Bear35645B Offline
        Bear35645
        wrote on last edited by
        #3

        So if I don't want to statically link, and use dlls instead, I have import the dll in my C code?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          No, the code doesn't change at all, you just link to the import library rather than the static.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • Bear35645B Offline
            Bear35645B Offline
            Bear35645
            wrote on last edited by
            #5

            When I direct the pro file to the directory where the DLLs reside, and try to use them in my .pro file it complains it can't find avcodec-53.lib. Here is the section of the .pro file in question.

            LIBS += -LC:\QtMEL_FFmpeg\lib
            -lavcodec-53
            -lavformat-53
            -lswscale-2
            -lavutil-51 \

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Might be a silly question, but did you check that you have the import libs available ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1
              • A Offline
                A Offline
                alex_malyu
                wrote on last edited by alex_malyu
                #7

                Linking against *lib file does not make it linking statically.

                I will simplify a bit.
                Linker needs both declaration and code.
                static library *.lib file contains both.

                Dynamic library has only code. Technically it is possible to call function from dll by address if you know
                its declaration at runtime.

                But unless you really need delay loading normally when dll is built appropriate lib file is built.
                Such lib file contains lets say exported symbol declaration but no code.

                So you link against lib in any case. Such lib files are different though.

                Alex

                1 Reply Last reply
                1
                • Bear35645B Offline
                  Bear35645B Offline
                  Bear35645
                  wrote on last edited by
                  #8

                  Thanks guys, I had to download a totally separate zip file to get the libs. I have another unrelated linking error, that I will post in another thread.

                  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