Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

I want to link DLLs not Static Libraries



  • 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?


  • Lifetime Qt Champion

    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



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


  • Lifetime Qt Champion

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



  • 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 \


  • Lifetime Qt Champion

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



  • 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



  • 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.


Log in to reply