Qt undefined reference to 3rdparty software libraries

北城余情 提交于 2019-12-11 10:26:58

问题


I using 3rd party library functions in my Qt application, but it's reporting errors such as "undefined reference to bp_attach collect2 : error: ld returned 1 exit status".

I have build 3rd party library (ion-dtn) from source code and did make & make install. I am certain that it has installed successfully in my Ubuntu system.

I have included its header file "bp.h" and Qt doesn’t complain about that. But when I compile I get the error mentioned above. Here is my .pro file:

QT       += core gui
QT       += network

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = MYUDP
TEMPLATE = app

INCLUDEPATH += /usr/local/include/
LIBS += -L /usr/local/lib

PKGCONFIG +=ion-d
SOURCES += main.cpp\
        myudp.cpp

HEADERS  += myudp.h

FORMS    += myudp.ui

Path of "bp.h" where bp_attach function is declared is /usr/local/include/bp.h.

Libs for 3rd party library are installed in /usr/local/lib and is defined in .pro.


回答1:


Although you have told QMake where to find the headers and the libraries, you need to specify which libraries need to be linked. The QMake equivalent to LDLIBS is LIBS:

INCLUDEPATH += /usr/local/include
LIBS += -lbp



回答2:


Probably this will help:

LIBS += -L /usr/local/lib -l**You_library_Name**


来源:https://stackoverflow.com/questions/34154253/qt-undefined-reference-to-3rdparty-software-libraries

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!