Important: Please read the Qt Code of Conduct -

Static compile of Qt Charts

  • What is the proper option for the command-line? I tried -qt-charts and -charts, but both are unknown options.


  • Lifetime Qt Champion


    What version of Qt are you trying to build ?
    Which option did you give to configure ?

  • Sorry, I'm doing a static build of Qt 5.8, and would like charts included.

    /Users/jedd/qt5.8/src/qtbase/configure -top-level -qt-charts -no-opengl -no-fontconfig -release -qt-libpng -qt-zlib -qt-freetype -static -prefix /Users/jedd/Qt/5.8/static -confirm-license -opensource -nomake examples -no-xcb-xlib -qt-xcb -no-dbus -nomake tests -skip declarative -qt-xkbcommon

    ERROR: Unknown command line option '-qt-charts'.

    I'm currently working on OS X, will compile same for Linux,Windows.

  • Lifetime Qt Champion

    Why the -no-opengl option in the case of macOS ?

    AFAIK, it's the other way around. you add -skip module_name to not build one.

  • BTW, running configure --help didn't show any qtchart options, nor did I find any references in qfeatures.txt

  • Lifetime Qt Champion

    It's a module not an option like the SQL drivers.

  • So it's built by default? OK, let me check my installation.

    OK, my static build is missing /lib/libQt5Charts_debug.a

    Or that's what happens when I attempt a build of the piechart example/

    make: *** No rule to make target /Users/jedd/Qt/5.8/static/lib/libQt5Charts_debug.a', needed'. Stop.

    piechart builds fine dynamically.

    I'll look at compiling charts separately?

  • Lifetime Qt Champion

    Yes you can build the module by hand.

    If you did an out of source build, then just create the qtcharts folder there and use the classic combo of qmake/make/make install.

  • Got it. Compiled qtcharts and copied the .a file to my static 5.8, then added:

    LIBS += -lQt5Charts

    To my .pro file.

  • Lifetime Qt Champion

    QT += charts should be enough in your .pro file

  • Great, thanks for your replies!

  • @SGaist

    I have come across the same problem. I have a fully working dynamic build but have now tried a static build of Qt. However, after successfully building Qt statically and try to run, I get the following error:

    :-1: error: Unknown module(s) in QT: charts datavisualization help

    Apologies if this is a basic question, but could you please explain (for dummies) how to "build the module by hand"?

    Edit: to complete a static build, I ran:

    configure -opensource -confirm-license -static -platform win32-g++ -opengl desktop -prefix "C:\Qt\5.12.6\mingw73_64_static" -skip webengine -nomake tests -nomake examples
    mingw32-make install
    mingw32-make clean

  • Lifetime Qt Champion

    @AhmedAlshawi hi, if you don't have QtCharts as part of your sources, you have to first download it.

    Then the classic qmake/make/make install applies. Note that I recommend using out of source builds.

  • @SGaist Thanks for the quick reply. I must admit I do not understand what the 'classic qmake/make/make install' means.

    I downloaded the sources package as part of the installation for Qt, and within my sources folder 'Src' I do have the 'qtcharts' folder, but I do not have 'qthelp' or 'qtdatavisualisation' in the folder.

    To build, should I copy the 'qtcharts' folder out of 'Src' and then build it? and how do I 'build' it?

    Thanks a lot!

  • Lifetime Qt Champion

    No, the idea is to create a folder outside of the source tree and do the build there.

    For example:

    mkdir -p /Users/jedd/build/qtcharts
    cd /Users/jedd/build/qtcharts
    /path/to/your/self_built/Qt/bin/qmake /path/to/qtcharts
    make install

  • @SGaist So I followed the steps exactly and I get an error that 'make' can't be found.

    Here are the lines added into PATH

    Thank you :)

  • Lifetime Qt Champion

    I wrote for a *nix OS.

    In your case it's "mingw32-make".

  • @SGaist Amazing thank you!! Worked a treat!

    I now still get 'datavisualization' and 'help' as unknown modules, but I can't find these in the 'Src' folder. Can I download them separately or are they hidden somewhere?

    Also, when I try and build my project using this static build, I have added "CONFIG += static" to the .pro file, but get these two errors:

    1. :-1: error: Cannot find windeployqt.exe in "C:\Qt\5.12.6\mingw73_64_static\bin".
    2. Cannot find winrtrunner.exe in "C:\Qt\5.12.6\mingw73_64_static\bin"

    Any help is much appreciated. Cheers.

  • Lifetime Qt Champion

    The help module likely comes from qttools as well as windeployqt.

    All the sources should be available from the installer, but if not, then you can clone them from

  • @SGaist
    Thank you so much, I built qttools in the same way and it fixed my problem completely!

Log in to reply