Search code examples
c++qtdlllinkerundefined-reference

How to link libraries in Qt project?


I'm trying to add parts of directshow example from libirimager library to my own Qt project. I can't link IRImager class. It has only header IRImager.h in sdk directory. In my main.cpp I just added IRImager class just like in directshow example:

#include <cstdio>
#include <iostream>

#include "thermovision_control_suite.h"
#include <QApplication>

// IR Imager imager interfaces
#include "IRImager.h"

evo::IRImager _imager;

int main(int argc, char *argv[]) {
    QApplication a(argc, argv);
    ThermovisionControlSuite w;
    w.show();
    return a.exec();
}

Here is the output:

error: undefined reference to `__imp__ZN3evo8IRImagerD1Ev'
error: undefined reference to `__imp__ZN3evo8IRImagerC1Ev'

In my thermovision_control_suite.pro file I added this lines:

INCLUDEPATH += $$PWD/sdk
DEPENDPATH += $$PWD/sdk

LIBS += $$PWD/sdk/x64/libirextras.dll \
        $$PWD/sdk/x64/libirextrasd.dll \
        $$PWD/sdk/x64/libirimager.dll \
        $$PWD/sdk/x64/libirimagerd.dll

It seems like sdk contains all needed for directshow example and it builds from source in Visual Studio project without any problems. Something is missing in my Qt project. Please help me to understand what is wrong.


Solution

  • Found an alternative solution. You can use the extension in Visual Studio to configure work with Qt: https://musescore.org/en/handbook/developers-handbook/compilation/compile-instructions-windows-visual-studio