Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to use QtPDF with MinGW + cmake ?
QtWS25 Last Chance

How to use QtPDF with MinGW + cmake ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 233 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    BushyAxis793
    wrote on last edited by
    #1

    Hello,

    I working on project which I want to create pdf file with workers data. I decided to use QtPdf which I used first time for MacOS version and everything was fine. However, now I want to prepare version for Windows with MinGW. But when I added QtPdf to my project I got several errors.

    Below is my CMakeLists.txt:

    cmake_minimum_required(VERSION 3.5)
    
    project(ORPHEUS VERSION 0.1 LANGUAGES CXX)
    
    set(CMAKE_AUTOUIC ON)
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_AUTORCC ON)
    
    set(CMAKE_CXX_STANDARD 17)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    
    find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
    find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
    find_package(Qt6 REQUIRED COMPONENTS Sql)
    find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets PrintSupport Pdf)
    
    set(LIBRARY_PATH C:/Repositories/logger/build/Desktop_Qt_6_3_0_MinGW_64bit-Debug)
    
    include_directories(C:/Repositories/logger)
    
    set(PROJECT_SOURCES
            main.cpp
            mainwindow.cpp
            mainwindow.h
            mainwindow.ui
            Constants.h
            database.h
            database.cpp
    )
    
    if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
        qt_add_executable(ORPHEUS
            MANUAL_FINALIZATION
            ${PROJECT_SOURCES}
            workerdialog.h
            workerdialog.cpp
            workerdialog.ui
            Constants.h
            worktimemodel.h
            worktimemodel.cpp
            database.h
            database.cpp
            workerstablemodel.h
            workerstablemodel.cpp
            workplacesdialog.h
            workplacesdialog.cpp
            workplacesdialog.ui
            workerhistorymodel.h
            workerhistorymodel.cpp
            workerhistorydialog.h
            workerhistorydialog.cpp
            workerhistorydialog.ui
            logindialog.h
            logindialog.cpp
            logindialog.ui
            registerdialog.h
            registerdialog.cpp registerdialog.ui
            pdfcreator.h
            pdfcreator.cpp
            exportdatadialog.h
            exportdatadialog.cpp
            exportdatadialog.ui
            config.json
    
        )
    # Define target properties for Android with Qt 6 as:
    #    set_property(TARGET ORPHEUS APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
    #                 ${CMAKE_CURRENT_SOURCE_DIR}/android)
    # For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
    else()
        if(ANDROID)
            add_library(ORPHEUS SHARED
                ${PROJECT_SOURCES}
            )
    # Define properties for Android with Qt 5 after find_package() calls as:
    #    set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
        else()
            add_executable(ORPHEUS
                ${PROJECT_SOURCES}
            )
        endif()
    endif()
    
    
    target_link_libraries(ORPHEUS PRIVATE
        Qt${QT_VERSION_MAJOR}::Widgets
        Qt6::Sql
        Qt6::Core Qt6::Gui Qt6::Widgets Qt6::PrintSupport Qt6::Pdf
        "${LIBRARY_PATH}/LoggerLibrary.lib"
    )
    
    add_custom_command(TARGET ORPHEUS POST_BUILD
        COMMAND ${CMAKE_COMMAND} -E copy_if_different
        "${LIBRARY_PATH}/LoggerLibrary.dll"
        $<TARGET_FILE_DIR:ORPHEUS>
    )
    
    include(FetchContent)
    FetchContent_Declare(
        nlohmann_json
        GIT_REPOSITORY https://github.com/nlohmann/json.git
        GIT_TAG v3.11.2
    )
    FetchContent_MakeAvailable(nlohmann_json)
    
    target_link_libraries(ORPHEUS PRIVATE nlohmann_json::nlohmann_json)
    target_link_libraries(ORPHEUS PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
    target_link_libraries(ORPHEUS PRIVATE Qt6::Sql)
    #target_link_libraries(ORPHEUS PRIVATE Qt6::Core Qt6::Gui Qt6::Widgets Qt6::PrintSupport Qt6::Pdf)
    
    # Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
    # If you are developing for iOS or macOS you should consider setting an
    # explicit, fixed bundle identifier manually though.
    if(${QT_VERSION} VERSION_LESS 6.1.0)
      set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.ORPHEUS)
    endif()
    set_target_properties(ORPHEUS PROPERTIES
        ${BUNDLE_ID_OPTION}
        MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
        MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
        MACOSX_BUNDLE TRUE
        WIN32_EXECUTABLE TRUE
    )
    
    include(GNUInstallDirs)
    install(TARGETS ORPHEUS
        BUNDLE DESTINATION .
        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
        RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
    )
    
    if(QT_VERSION_MAJOR EQUAL 6)
        qt_finalize_executable(ORPHEUS)
    endif()
    
    

    And I got the errors:

    C:\Repositories\ORPHEUS\CMakeLists.txt:15: error: Unknown CMake command "_qt_internal_find_third_party_dependencies".
    
    Call stack:
      C:/Repositories/ORPHEUS/CMakeLists.txt:15 (find_package)
      C:/Qt/6.3.0/mingw_64/lib/cmake/Qt6/Qt6Config.cmake:213 (find_package)
      C:/Qt/6.3.0/mingw_64/lib/cmake/Qt6Pdf/Qt6PdfConfig.cmake:43 (include)
      C:/Qt/6.3.0/mingw_64/lib/cmake/Qt6Pdf/Qt6PdfDependencies.cmake:34 (_qt_internal_find_third_party_dependencies)
    
    C:\Repositories\ORPHEUS\CMakeLists.txt:15: warning: Found package configuration file:
    
      C:/Qt/6.3.0/mingw_64/lib/cmake/Qt6Pdf/Qt6PdfConfig.cmake
    
    but it set Qt6Pdf_FOUND to FALSE so package "Qt6Pdf" is considered to be
    NOT FOUND.
    
    Call stack:
      C:/Repositories/ORPHEUS/CMakeLists.txt:15 (find_package)
      C:/Qt/6.3.0/mingw_64/lib/cmake/Qt6/Qt6Config.cmake:213 (find_package)
    

    Build&Run: Qt 6.3.0 MinGW_64

    I would like to know how can I use QtPdf for my project with MinGW?
    Have a good day

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      AFAIK, QtPdf is part of QtWebEngine which underlying dependency does not support MinGW.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      JonBJ 1 Reply Last reply
      2
      • SGaistS SGaist

        Hi,

        AFAIK, QtPdf is part of QtWebEngine which underlying dependency does not support MinGW.

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #3

        @SGaist
        I did not realise that "QtPdf is part of QtWebEngine" and hence will not compile with MinGW.
        Since we field question about not being able to build webengine with MinGW pretty regularly, is there anywhere in the documentation which lists this, QtPDF and any other modules (e.g. Bluetooth, IIRC?) which will require MSVC under Windows, so that people know when starting out with MinGW?

        1 Reply Last reply
        1
        • B Offline
          B Offline
          BushyAxis793
          wrote on last edited by
          #4

          Thanks for your answer, gentlemen. Generally, I need two modules, QMySQL and QtPDF. I have recompiled QMySQL with MinGW, and QtPDF only with MSVC. If I understand correctly, the only way to make both QMySQL and QtPDF work for me will be to recompile the QMySQL plugin to MSVC. Probably.

          JonBJ 1 Reply Last reply
          0
          • B BushyAxis793

            Thanks for your answer, gentlemen. Generally, I need two modules, QMySQL and QtPDF. I have recompiled QMySQL with MinGW, and QtPDF only with MSVC. If I understand correctly, the only way to make both QMySQL and QtPDF work for me will be to recompile the QMySQL plugin to MSVC. Probably.

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #5

            @BushyAxis793 Correct. Everything must be same compilation/link chain.

            Christian EhrlicherC 1 Reply Last reply
            2
            • JonBJ JonB

              @BushyAxis793 Correct. Everything must be same compilation/link chain.

              Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @JonB https://bugreports.qt.io/browse/QTBUG-135100

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              1 Reply Last reply
              3

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved