Search code examples
qtdll

Qt adding dll and lib files to a project


I'm trying to include some library files to my Qt project. Its structure looks like this:

  • project.pro
  • libs\x64
    • file1.dll
    • file2.dll
    • file2.lib

I tried editing the LIBS variable in the .pro file, but I still get error cannot open file 'xxx.lib (or xxx.dll, depending what I tried in th e.pro file).

I tried adding the files like this:

LIBS += -Llibs\x64
LIBS += -lfile1
LIBS += -lfile2

or like this:

LIBS += libs\x64\file1.dll
LIBS += libs\x64\file2.lib
LIBS += libs\x64\file2.dll

whatever I tried, I got the error that a dll/lib file cannot be opened. So how can I add these files to my project?


Solution

  • Try it like this:

    LIBS += -L"$$PWD/libs/x64" -file1
    LIBS += -L"$$PWD/libs/x64" -file2
    

    The libs should go to the folder described, where $$PWD is the folder of the .pro file, and the dll-s should go next to the .exe file. Also don't forget to run qmake afterwards.