c++buildqt5qt-creatorpodofo

How to add PoDoFo external library to my C++ project in Qt Creator?


I am using Qt Creator, Qt6, C++ for my program.

I would like to use the PoDoFo library but I have no knowledge of how to add the library/headers so that I can use it in my project and build it.

I have downloaded the PoDoFo code, just can't find any guidance/tutorials on how to add PoDoFo specifically in Qt Creator.

Edit: I tried "Add Library" to my project and used external library option. Once I finish, I try to compile my code and I get an error "podofo-0.9.7\COPYING.LIB:-1: error: LNK1107: invalid or corrupt file: cannot read at 0x62DC"

I can include the podofo.h file but that will also throw this error:"podofo-0.9.7\src\podofo\base\PdfCompilerCompat.h:44: error: C1083: Cannot open include file: 'podofo_config.h': No such file or directory"

.pro file:

QT       += core gui sql printsupport

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++17

# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
#QMAKE_CXXFLAGS += -std=c++17


SOURCES += \
    addbookdialog.cpp \
    addbooksdialog.cpp \
    bookdetailswindow.cpp \
    bulkdetailsdialog.cpp \
    cleanebooksdialog.cpp \
    insertlinkdialog.cpp \
    inserttabledialog.cpp \
    linkcollectiondialog.cpp \
    linkmanagerwindow.cpp \
    main.cpp \
    mainwindow.cpp \
    searchnamedialog.cpp \
    summarywindow.cpp

HEADERS += \
    addbookdialog.h \
    addbooksdialog.h \
    bookdetailswindow.h \
    bulkdetailsdialog.h \
    cleanebooksdialog.h \
    common.h \
    insertlinkdialog.h \
    inserttabledialog.h \
    linkcollectiondialog.h \
    linkmanagerwindow.h \
    mainwindow.h \
    queries.h \
    searchnamedialog.h \
    summarywindow.h

FORMS += \
    addbookdialog.ui \
    addbooksdialog.ui \
    bookdetailswindow.ui \
    bulkdetailsdialog.ui \
    cleanebooksdialog.ui \
    insertlinkdialog.ui \
    inserttabledialog.ui \
    linkcollectiondialog.ui \
    linkmanagerwindow.ui \
    mainwindow.ui \
    searchnamedialog.ui \
    summarywindow.ui

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

DISTFILES += \
    style.qss

RESOURCES += \
    images.qrc \
    style.qrc

unix|win32: LIBS += -L$$PWD/3rdparty/podofo-0.9.7/ -lCOPYING

INCLUDEPATH += $$PWD/3rdparty/podofo-0.9.7/src/podofo
DEPENDPATH += $$PWD/3rdparty/podofo-0.9.7/src/podofo

qt creator add library dialog: enter image description here


Solution

  • Did you take a look on this link: https://doc.qt.io/qt-5/third-party-libraries.html?

    I just followed it and my 3rdParty library (https://github.com/cutelyst/simple-mail) was linked and accessible from my application C++. Basically, your .pro file will look like this after setting everything properly:

    TARGET = MyQtApp
    
    TEMPLATE = app
    
    INCLUDEPATH += 3rdparty/CatWhisperer/include
    
    SOURCES += src/main.cpp
    
    LIBS += -L"3rdparty/CatWhisperer/lib" -lCatWhisperer