c++qtundefined-referenceopenalpr

QT, undefined reference to `alpr::Alpr::~Alpr()'


I am trying to run OpenALPR on QT. I installed it here. I can test it from terminal successfully. I got the error in the title on QT. Undefined reference error is caused by unlinked library but I add the libopenalpr.so under the path /usr/lib to the .pro file. Why I get that error?

My cpp file:

#include "alpr.h"
int main()
{
    alpr::Alpr openalpr("us", "etc/openalpr/openalpr.conf");
}

My pro file:

QT += core
QT -= gui
TARGET = OpenAlprTry
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
LIBS += -L -lopenalpr

Solution

  • You can use pkg-config to link with your wanted library. Add to .pro file:

    unix: CONFIG += link_pkgconfig
    unix: PKGCONFIG += openalpr
    

    Package name could be different or you could need to add more packages.

    To check pkg-config names type in your terminal:

    pkg-config --list-all | grep openalpr
    

    and add packages like that

    unix: PKGCONFIG += package1 package2 package3