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

How to use KDCharts from GitHub on Windows?



  • Hi,
    Re: can't install KD Reports

    This topic is from 2017. Now the year is 2020 and I can not install and use this library unfortunatelly.

    I asked to KDAB and they said that they stopped maintenance the library.

    Is there anyone who can install and use this library in their Qt projects?!

    Especially the Gantt Diagram.

    Regards,
    Mukcip:)



    1. Install MSVC (aka Visual Studio)
    2. Install Qt5 for MSVC
    3. Install CMake (https://cmake.org/)
    4. open a command prompt and run both qtenv2.bat (from the Qt folder) and vcvarsall.bat x64 (from the Visual Studio Folder)
    5. Prepend the path to cmake.exe to your PATH env variable: SET PATH=C:\Program Files\CMake;%PATH%
    6. download the sources of kdchart
    7. navigate the command prompt to that folder
    8. Run the following commands:
    mkdir build
    cd build
    cmake -G "NMake Makefiles" -DCMAKE_DEBUG_POSTFIX=d -DCMAKE_INSTALL_PREFIX=C:/KDCharts -DCMAKE_BUILD_TYPE=DEBUG ../
    cmake --build .
    cmake --build . --target install
    cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=C:/KDCharts -DCMAKE_BUILD_TYPE=RELEASE ../
    cmake --build .
    cmake --build . --target install
    

  • Qt Champions 2019

    As always: what did you do and what did not work?



  • Hi,
    I use Qt 5.13.2 on Win10x64

    I followed what the install.txt says.
    I run python autogen.py and created cofigure.bat.

    and the result is:

    C:\Users\mucip\Documents\Qt\KDChart>configure.bat
    Qt found: C:/Qt/5.13.2/msvc2017_64
      Release.................: yes (default: yes)
      Shared build............: yes (default: yes)
      Compiled-In Unit Tests..: no (default: no)
    
    Project ERROR: Cannot run compiler 'cl'. Output:
    ===================
    ===================
    Maybe you forgot to setup the environment?
    qmake failed
    C:\Users\mucip\Documents\Qt\KDChart>
    

    Regards,
    Mucip:)


  • Qt Champions 2019

    @Mucip If you're using Microsoft compiler then you should start the MSVC console where everything is prepared and build in that console.



  • Hi @jsulm ,
    This is also msvc2017 64-bit console...

    Regards,
    Mucip:)


  • Qt Champions 2019

    @Mucip And you can run cl.exe from that console?
    Did you check the configure log?



  • Hi @jsulm ,
    Interesting?

    C:\Users\mucip\Documents\Qt\KDChart>cl.exe
    'cl.exe' is not recognized as an internal or external command,
    operable program or batch file.
    

    Regards,
    Mucip:)


  • Qt Champions 2019

    @Mucip Are you sure you're using the MSVC console?
    You can try to add the path to cl.exe directory to PATH before calling configure.exe, but I fear you will have other issues.



  • Hi @jsulm,
    Did I wrong?
    I will execute this console:

    C:\Windows\System32\cmd.exe /A /Q /K C:\Qt\5.13.2\msvc2017_64\bin\qtenv2.bat
    

    By the way where is cl.exe?

    Regards,
    Mucip:)


  • Qt Champions 2019

    @Mucip There should be an entry in the start menu for that



  • @jsulm ,
    Yes. there is link in the start menu .

    Where is cl.exe? Or where shoul I install it?

    Regards,
    Mucip:)


  • Qt Champions 2019

    @Mucip said in How to use KDCharts from GitHub on Windows?:

    Yes. there is link in the start menu

    So, did you try to use it?

    "Where is cl.exe?" - simply use search function in Windows Explorer.



  • Hi @jsulm ,
    I will from Google this.

    I added it to path

    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\bin\Hostx64\x64

    It satart to compile. When I run nmake some lines appear in the console but error come up:

    'rc' is not recognized as an internal or external command,
    operable program or batch file.
    NMAKE : fatal error U1077: 'rc' : Return code '0x1'
    Stop.
    NMAKE : fatal error U1077: 'cd' : Return code '0x2'
    Stop.
    
    C:\Users\mucip\Documents\Qt\KDChart>
    

    Regards,
    Mucip:)


  • Qt Champions 2019

    @Mucip You still did not answer the question regarding MSVC console short-cut in start menu: did you try to use it?
    And there is actually no need for an YouTube video to find a file...



  • @jsulm ,
    Yes I use MSVC2017 64 bit console from start menu which comes with Qt instalation.

    Regards,
    Mucip:)



  • @jsulm
    I added rc.exe and others in the PATH and restart configure.bat and nmake command.

    nmake result error message is:

    rc /NOLOGO -DUNICODE -D_UNICODE -DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DWIN64 -DNDEBUG -DUSE_EXCEPTIONS -DKDCHART_VERSION=200 -DKDCHART_MASTER_CVS -DQT_FATAL_ASSERT -DQT_NO_STL -DQT_NO_CAST_TO_ASCII -DQBA_NO_CAST_TO_VOID -DQBA_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DNOMINMAX -D_USE_MATH_DEFINES -DKDCHART_SHAREDLIB -DKDCHART_BUILD_KDCHART_LIB -DQT_NO_KEYWORDS -Demit= -DQT_NO_DEBUG -DQT_SVG_LIB -DQT_PRINTSUPPORT_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -D_WINDLL -fo release\_obj\kdchart_resource.res kdchart_resource.rc
    kdchart_resource.rc(1) : fatal error RC1015: cannot open include file 'windows.h'.
    NMAKE : fatal error U1077: '"C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x64\rc.EXE"' : Return code '0x1'
    Stop.
    NMAKE : fatal error U1077: 'cd' : Return code '0x2'
    Stop.
    
    C:\Users\mucip\Documents\Qt\KDChart>
    

    Regards,
    Mucip:)


  • Qt Champions 2019

    @Mucip said in How to use KDCharts from GitHub on Windows?:

    Yes I use MSVC2017 64 bit console from start menu which comes with Qt instalation.

    But you have Visual Studio 2019? I'm not sure it is going to work. You can try the console from Visual Studio - I'm not a Visual Studio expert but I think there is a console.



    1. Install MSVC (aka Visual Studio)
    2. Install Qt5 for MSVC
    3. Install CMake (https://cmake.org/)
    4. open a command prompt and run both qtenv2.bat (from the Qt folder) and vcvarsall.bat x64 (from the Visual Studio Folder)
    5. Prepend the path to cmake.exe to your PATH env variable: SET PATH=C:\Program Files\CMake;%PATH%
    6. download the sources of kdchart
    7. navigate the command prompt to that folder
    8. Run the following commands:
    mkdir build
    cd build
    cmake -G "NMake Makefiles" -DCMAKE_DEBUG_POSTFIX=d -DCMAKE_INSTALL_PREFIX=C:/KDCharts -DCMAKE_BUILD_TYPE=DEBUG ../
    cmake --build .
    cmake --build . --target install
    cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=C:/KDCharts -DCMAKE_BUILD_TYPE=RELEASE ../
    cmake --build .
    cmake --build . --target install
    


  • Hi @VRonin ,
    I applied your list but there is error. I think it's because of VS2019 or my path variables?!

    C:\Users\mucip\Documents\Qt\KDChart\build>cmake -G "NMake Makefiles" -DCMAKE_DEBUG_POSTFIX=d -DCMAKE_INSTALL_PREFIX=C:/KDCharts -DCMAKE_BUILD_TYPE=DEBUG ../
    -- The CXX compiler identification is MSVC 19.23.28106.4
    -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe
    -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe - broken
    CMake Error at C:/Program Files/CMake/share/cmake-3.17/Modules/CMakeTestCXXCompiler.cmake:53 (message):
      The C++ compiler
    
        "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe"
    
      is not able to compile a simple test program.
    
      It fails with the following output:
    
        Change Dir: C:/Users/mucip/Documents/Qt/KDChart/build/CMakeFiles/CMakeTmp
    
        Run Build Command(s):nmake /nologo cmTC_f17e3\fast &&       "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\bin\Hostx64\x64\nmake.exe" -f CMakeFiles\cmTC_f17e3.dir\build.make /nologo -L                  CMakeFiles\cmTC_f17e3.dir\build
        Building CXX object CMakeFiles/cmTC_f17e3.dir/testCXXCompiler.cxx.obj
            C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1423~1.281\bin\Hostx64\x64\cl.exe @C:\Users\mucip\AppData\Local\Temp\nm72D3.tmp
        testCXXCompiler.cxx
        Linking CXX executable cmTC_f17e3.exe
            "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_f17e3.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100183~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100183~1.0\x64\mt.exe --manifests  -- C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1423~1.281\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\cmTC_f17e3.dir\objects1.rsp @C:\Users\mucip\AppData\Local\Temp\nm745B.tmp
        LINK Pass 1: command "C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1423~1.281\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\cmTC_f17e3.dir\objects1.rsp /out:cmTC_f17e3.exe /implib:cmTC_f17e3.lib /pdb:C:\Users\mucip\Documents\Qt\KDChart\build\CMakeFiles\CMakeTmp\cmTC_f17e3.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles\cmTC_f17e3.dir/intermediate.manifest CMakeFiles\cmTC_f17e3.dir/manifest.res" failed (exit code 1104) with the following output:
        LINK : fatal error LNK1104: 'kernel32.lib' dosyas² a²lam²yor
        NMAKE : fatal error U1077: '"C:\Program Files\CMake\bin\cmake.exe"' : D÷n³■ kodu '0xffffffff'
        Stop.
        NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\bin\Hostx64\x64\nmake.exe"' : D÷n³■ kodu '0x2'
        Stop.
    
    
    
    
    
      CMake will not be able to correctly generate this project.
    Call Stack (most recent call first):
      CMakeLists.txt:40 (project)
    
    
    -- Configuring incomplete, errors occurred!
    See also "C:/Users/mucip/Documents/Qt/KDChart/build/CMakeFiles/CMakeOutput.log".
    See also "C:/Users/mucip/Documents/Qt/KDChart/build/CMakeFiles/CMakeError.log".
    
    C:\Users\mucip\Documents\Qt\KDChart\build>
    

    Regards,
    Mucip:)



  • @Mucip said in How to use KDCharts from GitHub on Windows?:

    I think it's because of VS2019 or my path variables?!

    Did you run vcvarsall.bat x64 as mentioned in step 4? and I don't mean double-clicking on the file but using the command line to execute them



  • @VRonin ,
    I run below command in MSVC2019 console:

    C:\Users\mucip\Documents\Qt\KDChart\build>"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
    

    It's building now. I think it will be ok. Thanks :)

    Regards,
    Mucip:)



  • @VRonin ,
    I build library and add all necessary things in pro file:

    QT       += core gui
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    CONFIG += c++11
    
    # The following define makes your compiler emit warnings if you use
    # any Qt feature that has been marked deprecated (the exact warnings
    # depend on your compiler). Please consult the documentation of the
    # deprecated API in order to know how to port your code away from it.
    DEFINES += QT_DEPRECATED_WARNINGS
    
    # You can also make your code fail to compile if it uses deprecated APIs.
    # In order to do so, uncomment the following line.
    # You can also select to disable deprecated APIs only up to a certain version of Qt.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    
    SOURCES += \
        main.cpp \
        mainwindow.cpp
    
    HEADERS += \
        mainwindow.h
    
    FORMS += \
        mainwindow.ui
    
    # Default rules for deployment.
    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target
    
    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../KDCharts/lib/ -lkdchart2
    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../KDCharts/lib/ -lkdchart2d
    # else:unix:!macx: LIBS += -L$$PWD/../KDCharts/lib/ -lkdchart2
    
    
    
    
    
    INCLUDEPATH += $$PWD/../KDCharts/include/KDChart
    DEPENDPATH += $$PWD/../KDCharts/include/KDChart
    

    I can add the includes without erro in mainWindow.h file

    #include <KDChartChart>
    #include <KDChartLineDiagram>
    
    

    Then in cpp file:

    //Add the widget to your layout like any other QWidget:
        QHBoxLayout* chartLayout = new QHBoxLayout(ui->chartFrame);
        KDChart::Chart *m_chart = new KDChart::Chart(this);
        chartLayout->addWidget( m_chart );
    

    But I can not run the code. It crush without message. Only this:

    22:40:54: Starting C:\Users\mucip\Documents\Qt\build-KDChartdYeniDeneme-Desktop_Qt_5_13_2_MSVC2017_64bit-Release\release\KDChartdYeniDeneme.exe ...
    22:40:54: The program has unexpectedly finished.
    22:40:54: The process was ended forcefully.
    22:40:54: C:\Users\mucip\Documents\Qt\build-KDChartdYeniDeneme-Desktop_Qt_5_13_2_MSVC2017_64bit-Release\release\KDChartdYeniDeneme.exe crashed.
    

    I run debugger but nothings happend?! I use MSVC2019. May it be because of newest version of VS?

    Regards,
    Mucip:)



  • Hi,
    Missing DLL's. Sorry...
    I coppied DLL's from KDCharts/bin directory to build directory.

    Regards,
    Mucip:)



  • @Mucip said in How to use KDCharts from GitHub on Windows?:

    -L$$PWD/../KDCharts/lib/

    Relative paths are often inadvisable, use the full absolute path -LC:/KDCharts/lib/

    I coppied DLL's from KDCharts/bin directory to build directory.

    This is bad. You should add the path to those DLLs to the "run environment" options of Qt Creator



  • Hi @VRonin ,
    OK. I will care about this advice. Thanks. ;)

    Regards,
    Mucip:)


Log in to reply