Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QtCharts installation on Ubuntu



  • I recently installed Ubuntu 20.04 where Qt 5.12.8 is the bundled with the operating system. However Ubuntu did not supply either Qt MaintenanceTool or QtCharts. I wish to install QtCharts, but without MaintenanceTool it is impossible. What is the easiest way of getting QtCharts installed on my system?


  • Moderators

    I still don't get what the problem is...

    if you want to distribute your app on linux - don't distribute a binary, deploy to some packaging solution instead (DEB, RPM etc.) - this way the system will make sure that all necessary libs are installed, and it will be done automatically.

    Or do a standalone package (AppImage, snap, Flatpak) which will bundle everything inside - then you also don't need to worry about any libs.

    However, I have a cmake-based system

    The procedure for cmake is the same, only the syntax a bit different:

    find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
    find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Charts REQUIRED)
    # then make sure to link to Charts when building your app
    target_link_libraries (yourApp Qt${QT_VERSION_MAJOR}::Charts)
    

  • Lifetime Qt Champion

    @willemf said in QtCharts installation on Ubuntu:

    What is the easiest way of getting QtCharts installed on my system?

    Use the Qt online installer to install a recent Qt version together with QtCharts (you also will have the maintenance tool then).
    Or are you bound to the Qt version Ubuntu is providing?


  • Moderators

    You need to install this package:

    sudo apt install libqt5charts5-dev
    

    Please remember that QtCharts are not available under LGPL license (only GPLv3).



  • @sierdzio

    I installed the library. However, when I do
    #include <QtCharts> in a cpp header file
    I get an error "No such file"

    Since Qt components are not all installed in the same place in the system area, it's not easily possible to upgrade (or even delete) the bundled version. So I am stuck with the bundled Qt.


  • Lifetime Qt Champion

    @willemf Did you add

    QT += charts
    

    to your pro file as explained in the documentation?


  • Moderators

    @willemf said in QtCharts installation on Ubuntu:

    @sierdzio

    I installed the library. However, when I do
    #include <QtCharts> in a cpp header file
    I get an error "No such file"

    You need to add the module in your .pro (or cmake) file:

    QT += charts
    

    Since Qt components are not all installed in the same place in the system area, it's not easily possible to upgrade (or even delete) the bundled version. So I am stuck with the bundled Qt.

    I don't understand what you mean to say here.



  • @sierdzio
    When installing Qt from the Qt web site, the whole of Qt resides in a single folder, typically someting like:
    Qt/5.12.8/

    The bundled Qt in Ubuntu is not in a single folder, e.g. the header files are in usr/incude/x86_64-linux-gnu/qt5

    I have:
    // ----------------------------------------------------------------------------------
    willem[~]$ dpkg -s libqt5charts5-dev
    Package: libqt5charts5-dev
    Status: install ok installed
    Priority: optional
    Section: libdevel
    Installed-Size: 286
    Maintainer: Ubuntu Developers ubuntu-devel-discuss@lists.ubuntu.com
    Architecture: amd64
    Multi-Arch: same
    Source: qtcharts-opensource-src
    Version: 5.12.8-0ubuntu1
    Depends: libqt5charts5 (= 5.12.8-0ubuntu1), qtbase5-dev
    Description: Qt charts development files
    Qt Charts module provides a set of easy to use chart components.
    .
    This package contains the header development files used for building Qt 5
    applications using QtCharts.
    Homepage: https://doc.qt.io/qt-5/qtcharts-index.html
    Original-Maintainer: Debian Qt/KDE Maintainers debian-qt-kde@lists.debian.org
    // -----------------------------------------------------------------------------------
    This means the header files are in place. Indeed, I find the header files in usr/incude/x86_64-linux-gnu/qt5

    I need away to verify that the correct library is loaded, as opposed to the header file package.

    So, I need the library against which these headers can link, typically performed using
    QT += charts
    in a qmake-based system.

    However, I have a cmake-based system.

    How can one verify that the library exists on one's linux box?


  • Lifetime Qt Champion

    @willemf said in QtCharts installation on Ubuntu:

    How can one verify that the library exists on one's linux box?

    Simply check whether the related Ubuntu packages are installed...
    Like libqt5charts5-dev which was pointed out in this thread.


  • Moderators

    I still don't get what the problem is...

    if you want to distribute your app on linux - don't distribute a binary, deploy to some packaging solution instead (DEB, RPM etc.) - this way the system will make sure that all necessary libs are installed, and it will be done automatically.

    Or do a standalone package (AppImage, snap, Flatpak) which will bundle everything inside - then you also don't need to worry about any libs.

    However, I have a cmake-based system

    The procedure for cmake is the same, only the syntax a bit different:

    find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
    find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Charts REQUIRED)
    # then make sure to link to Charts when building your app
    target_link_libraries (yourApp Qt${QT_VERSION_MAJOR}::Charts)
    


  • @sierdzio
    This helped very much.
    Thank oyu.


Log in to reply