Qt World Summit: Register Today!

How to include library in a local directory in build?

  • I'm trying to link to a third party library. I'd like to configure LIBS to refer to a local directory. When I use an absolute path (the first line below), I can link. However my other attempts to link in a local directory are failing.

    What is the syntax to include a local directory in LIBS?

    win32 {
    LIBS += -LD:\bin\ffmpeg-20190403-b131a07-win32-dev\lib
    #LIBS += -L./thirdParty/ffmpeg/win32/lib
    #LIBS += -LthirdParty/ffmpeg/win32/lib
    LIBS += -lavcodec -lavformat -lavutil -lswscale -lswresample

  • Lifetime Qt Champion

    Did you try with
    LIBS += -L$$PWD/thirdParty/ffmpeg/win32/lib

    That is assuming that thirdParty is a subfolder to the folder where the .pro file is.

  • That worked!

  • Lifetime Qt Champion

    The reason the
    #LIBS += -L./thirdParty/ffmpeg/win32/lib
    #LIBS += -LthirdParty/ffmpeg/win32/lib

    didn't work is that - at the time of invocation of the linker, the current directory is
    likely the build folder so the linker would try to find the libs relative to that folder.

    However, $$PWD is "where .pro file is" and hence the relative path can then work.

Log in to reply