How to use KDCharts from GitHub on Windows?
-
@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:) -
- Install MSVC (aka Visual Studio)
- Install Qt5 for MSVC
- Install CMake (https://cmake.org/)
- open a command prompt and run both
qtenv2.bat
(from the Qt folder) andvcvarsall.bat x64
(from the Visual Studio Folder) - Prepend the path to cmake.exe to your PATH env variable:
SET PATH=C:\Program Files\CMake;%PATH%
- download the sources of kdchart
- navigate the command prompt to that folder
- 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
@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:) -
@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:) -
@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:)@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
-
@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