1
votes

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?

1
Try right click on the project name - > add libraryJLev
@JLev I tried and there's still the same error: cannot open file file2.lib.T.Poe
Since when can you add a dll to your project? Isn't that only located and loaded on statup of your app?Martin Hennings
@MartinHennings I'm not really sure what I'm doing, but I found it here: wiki.qt.io/How_to_link_to_a_dllT.Poe

1 Answers

2
votes

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.