Problem installing Qt Charts



  • I have cloned the qtcharts project from github and I am trying to built it. I am using ubuntu, qmake version 3.0 and qt version 5.5.1. I get the following error when I try to build the project cloned from github:

    Makefile:3313: warning: ignoring old recipe for target '.obj/main.o'
    Makefile:3319: warning: overriding recipe for target '.obj/main.o'
    Makefile:3316: warning: ignoring old recipe for target '.obj/main.o'
    g++ -c -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -O2 -fno-exceptions -Wall -W -D_REENTRANT -fPIC -DQT_NO_TSLIB -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I. -I. -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I.moc -isystem /usr/include/libdrm -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -o .obj/qchartsplugin.o plugins/designer/qchartsplugin.cpp
    In file included from plugins/designer/qchartsplugin.cpp:30:0:
    plugins/designer/qchartsplugin.h:33:53: fatal error: QtDesigner/QDesignerCustomWidgetInterface: No such file or directory
    compilation terminated.
    Makefile:2450: recipe for target '.obj/qchartsplugin.o' failed

    make: *** [.obj/qchartsplugin.o] Error 1

    Is there anything else I should clone from github to run qtcharts?

    Thank you in advance.

    compilation terminated.

    Makefile:2450: recipe for target '.obj/qchartsplugin.o' failed
    make: *** [.obj/qchartsplugin.o] Error 1

    I am using qmake version 3.0
    and Qt version 5.5.1


  • Moderators

    Hi! Qt Charts is now part of the official release, just update to Qt 5.7.




  • Moderators

    @JosephC Add QT += charts in your .pro file and Run qmake.



  • @p3c0
    I have done that. That's my problem. Here is the answer:
    error: Unknown module(s) in QT: charts


  • Moderators

    @JosephC Did you install QtCharts after updating to 5.7? It looks like it is not installed by default and is listed as a module under Qt5.7 node in Qt Maintenance Tool.



  • I have the same problem. I just downloaded qt-everywhere-opensource-src-5.7.0.tar.gz, then I did:

    ./configure --prefix=$PWD/qtbase -opensource -nomake tests -confirm-license -c++std c++11 -qt-sql-sqlite -plugin-sql-sqlite -system-sqlite
    make -j4
    make install
    

    run through without issues.
    Then I added the base path manualy to QT Versions
    qt image
    then set it to default:
    alt text
    my project file:

    #-------------------------------------------------
    #
    # Project created by QtCreator 2016-09-26T09:00:37
    #
    #-------------------------------------------------
    
    QT       += core gui charts
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    TARGET = fileDialogTest
    TEMPLATE = app
    
    
    SOURCES += main.cpp\
            mainwindow.cpp
    
    HEADERS  += mainwindow.h
    
    FORMS    += mainwindow.ui
    

    when I build it I get "cannot find -lQt5Charts":

    09:43:45: Starting: "/usr/bin/make" 
    g++ -Wl,-rpath,/home/paul/build/qt-everywhere-opensource-src-5.7.0/qtbase/lib -o fileDialogTest main.o mainwindow.o moc_mainwindow.o   -L/home/paul/build/qt-everywhere-opensource-src-5.7.0/qtbase/lib -lQt5Charts -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread 
    /usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lQt5Charts
    Makefile:318: recipe for target 'fileDialogTest' failed
    collect2: error: ld returned 1 exit status
    make: *** [fileDialogTest] Error 1
    09:43:45: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project fileDialogTest (kit: QT 5.7.0)
    When executing step "Make"
    09:43:45: Elapsed time: 00:00.
    

    When I sear for it in the base dir I get:

    find build/qt-everywhere-opensource-src-5.7.0/qtbase/ -name '*Charts*'
    build/qt-everywhere-opensource-src-5.7.0/qtbase/lib/cmake/Qt5Charts
    build/qt-everywhere-opensource-src-5.7.0/qtbase/lib/cmake/Qt5Charts/Qt5ChartsConfigVersion.cmake
    build/qt-everywhere-opensource-src-5.7.0/qtbase/lib/cmake/Qt5Charts/Qt5ChartsConfig.cmake
    build/qt-everywhere-opensource-src-5.7.0/qtbase/lib/libQt5Charts.prl
    build/qt-everywhere-opensource-src-5.7.0/qtbase/lib/pkgconfig/Qt5Charts.pc
    build/qt-everywhere-opensource-src-5.7.0/qtbase/lib/libQt5Charts.la
    build/qt-everywhere-opensource-src-5.7.0/qtbase/include/QtCharts
    build/qt-everywhere-opensource-src-5.7.0/qtbase/include/QtCharts/QtChartsDepends
    build/qt-everywhere-opensource-src-5.7.0/qtbase/qml/QtCharts
    

    did I miss something?



  • I solved my problem. I had to extra build QtCharts from the source directory so it does not get built and installed by default configure/build of qtbase:

    cd qt-everywhere-opensource-src-5.7.0/qtcharts
    ../qtbase/bin/qmake
    make -j4
    make install
    

    After that I was able to build my Project.


  • Moderators

    @pauledd Do you really need to build Qt by yourself? Qt 5.7 binaries already contain QtCharts - you can install both using Qt Maintenance Tool.



  • @jsulm I used no binaries, I compiled everything from source. But it still doesnt work. I cant create a QLineSeries Object.

    ../fileDialogTest/mainwindow.cpp:27:2: error: 'QLineSeries' was not declared in this scope
      QLineSeries *a = new QLineSeries();
      ^
    ../fileDialogTest/mainwindow.cpp:27:2: note: suggested alternative:
    In file included from ../../build/qt-everywhere-opensource-src-5.7.0/qtcharts/include/QtCharts/qlineseries.h:1:0,
                     from ../../build/qt-everywhere-opensource-src-5.7.0/qtcharts/include/QtCharts/QtCharts:28,
                     from ../fileDialogTest/mainwindow.cpp:4:
    ../../build/qt-everywhere-opensource-src-5.7.0/qtcharts/include/QtCharts/../../src/charts/linechart/qlineseries.h:41:24: note:   'QtCharts::QLineSeries'
     class QT_CHARTS_EXPORT QLineSeries : public QXYSeries
    

    I will try the binaries now.



  • Maybe I choose the wrong license? I just read that QtCharts is available in GPLV2/GPLV3 but NOT in LGPLV3.



  • I tried the binary package but I get the same error.
    project file:

    SOURCES += \
        main.cpp
    CONFIG += qt 
    QT += core gui charts
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    

    main.cpp:

    #include <QApplication>
    #include <QLineSeries>
    #include <QChartView>
    int main(int argc, char **argv){
    	QApplication app(argc,argv);
    	
    	QLineSeries *ls = new QLineSeries;
    	
    	return app.exec();
    }
    

    output:

    11:29:40: Starting: "/usr/bin/make" 
    g++ -c -pipe -g -std=gnu++11 -D_REENTRANT -Wall -W -fPIC -DQT_CHARTS_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_QML_DEBUG -I../chartsTest2 -I. -I/home/paul/store/build/Qt5.7.0/5.7/gcc_64/include -I/home/paul/store/build/Qt5.7.0/5.7/gcc_64/include/QtCharts -I/home/paul/store/build/Qt5.7.0/5.7/gcc_64/include/QtWidgets -I/home/paul/store/build/Qt5.7.0/5.7/gcc_64/include/QtGui -I/home/paul/store/build/Qt5.7.0/5.7/gcc_64/include/QtCore -I. -I/home/paul/store/build/Qt5.7.0/5.7/gcc_64/mkspecs/linux-g++ -o main.o ../chartsTest2/main.cpp
    ../chartsTest2/main.cpp: In function 'int main(int, char**)':
    ../chartsTest2/main.cpp:7:2: error: 'QLineSeries' was not declared in this scope
      QLineSeries *ls = new QLineSeries;
      ^
    ../chartsTest2/main.cpp:7:2: note: suggested alternative:
    In file included from /home/paul/store/build/Qt5.7.0/5.7/gcc_64/include/QtCharts/QLineSeries:1:0,
                     from ../chartsTest2/main.cpp:2:
    /home/paul/store/build/Qt5.7.0/5.7/gcc_64/include/QtCharts/qlineseries.h:41:24: note:   'QtCharts::QLineSeries'
     class QT_CHARTS_EXPORT QLineSeries : public QXYSeries
                            ^
    ../chartsTest2/main.cpp:7:15: error: 'ls' was not declared in this scope
      QLineSeries *ls = new QLineSeries;
                   ^
    ../chartsTest2/main.cpp:7:24: error: 'QLineSeries' does not name a type
      QLineSeries *ls = new QLineSeries;
                            ^
    Makefile:658: recipe for target 'main.o' failed
    make: *** [main.o] Error 1
    11:29:41: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project chartsTest2 (kit: Desktop Qt 5.7.0 GCC 64bit)
    When executing step "Make"
    11:29:41: Elapsed time: 00:02.
    


  • ok, after

    #include <QtCharts>
    

    I can compile it.



  • add using namespace QtCharts;


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.