如何在Qt Creator中正确链接外部DLL

时间:2019-04-04 09:57:26

标签: c++ qt dll qt5 qmake

正在尝试构建项目,发现@ @ uconfig ,该项目需要poppler,而作者提供了预先构建的链接 headersDLLS

我已经下载了它们,这是项目的结构

enter image description here

dll 文件夹包含所有DLLS,而 poppler 包含头文件, pdf_extract.pro 具有以下内容

QT     += core gui widgets xml

TARGET = pdf_extract
TEMPLATE = lib
DEFINES += DATASHEET_EXTRACTOR_EXPORT_LIB
DESTDIR = "$$PWD/../../bin"

CONFIG(release, debug|release) {
    CONFIG += optimize_full
}

SOURCES += \
    $$PWD/datasheet.cpp \
    $$PWD/datasheetpackage.cpp \
    $$PWD/datasheetpin.cpp \
    $$PWD/datasheetbox.cpp \
    $$PWD/pdfdebugwidget/pdfdebugwidget.cpp \
    $$PWD/pdfdebugwidget/pdfdebugviewer.cpp \
    $$PWD/pdfdebugwidget/pdfdebugscene.cpp \
    $$PWD/pdfdebugwidget/pdfdebugitempage.cpp \
    $$PWD/pdfdebugwidget/pdfdebugitempin.cpp \
    $$PWD/pdfdebugwidget/pdfdebugitemtextbox.cpp \
    $$PWD/model/pdfdatasheet.cpp \
    $$PWD/model/pdfpage.cpp \
    $$PWD/model/pdftextbox.cpp \
    $$PWD/model/pdfpin.cpp \
    $$PWD/model/pdfcomponent.cpp \
    $$PWD/controller/pdfloader.cpp

HEADERS += \
    $$PWD/pdf_extract_common.h \
    $$PWD/datasheet.h \
    $$PWD/datasheetpackage.h \
    $$PWD/datasheetpin.h \
    $$PWD/datasheetbox.h \
    $$PWD/pdfdebugwidget/pdfdebugwidget.h \
    $$PWD/pdfdebugwidget/pdfdebugviewer.h \
    $$PWD/pdfdebugwidget/pdfdebugscene.h \
    $$PWD/pdfdebugwidget/pdfdebugitempage.h \
    $$PWD/pdfdebugwidget/pdfdebugitempin.h \
    $$PWD/pdfdebugwidget/pdfdebugitemtextbox.h \
    $$PWD/model/pdfdatasheet.h \
    $$PWD/model/pdfpage.h \
    $$PWD/model/pdftextbox.h \
    $$PWD/model/pdfpin.h \
    $$PWD/model/pdfcomponent.h \
    $$PWD/controller/pdfloader.h

LIBS += -L"$$PWD/../../bin"
LIBS += -L"$$PWD/dll/jpeg62.dll"
LIBS += -L"$$PWD/dll/libfreetype-6.dll"
LIBS += -L"$$PWD/dll/libopenjp2.dll"
LIBS += -L"$$PWD/dll/libpng12.dll"
LIBS += -L"$$PWD/dll/libpoppler-80.dll"
LIBS += -L"$$PWD/dll/libpoppler-qt5.dll"
LIBS += -L"$$PWD/dll/libtiff3.dll"
LIBS += -L"$$PWD/dll/zlib1.dll"

INCLUDEPATH += $$PWD/../../


LIBS += -lkicad

macx {
    LIBS += -L /usr/local/lib
    INCLUDEPATH += /usr/local/include 
}

但是,当我尝试构建项目时,出现了这些错误...不确定发生了什么错误或丢失

enter image description here

1 个答案:

答案 0 :(得分:1)

根据qmake documentation,使用unix标准指定链接库也可以在Windows上使用。无论如何,不​​是

LIBS += -L"$$PWD/dll/jpeg62.dll"

我会尝试

LIBS += "-L$$PWD/dll" - ljpeg62

或仅使用Windows样式:

LIBS += $$PWD/dll/jpeg62.dll