QtCharts causing linking errors (LNK2019)
-
@ashkan849
Hello,
First a very quick note. These types of includes:#include <qtcharts/qbarcategoryaxis>
will render your program uncompilable on any platform different from windows. My advice is to stick to the standard way of including the headers, i.e. respecting their case.
Now to the main problem, have installed the QtCharts module?Kind regards.
-
Yes I believe you are right, I think you mean that I should have it as:
#include <QtCharts/QBarCategoryAxis>
I have installed Qt 5.7 for VS2013 (32 bit), which includes the source files for QtCharts in the folder <Qt directory>\5.7\msvc2013\include\QtCharts. Is that sufficient?
-
Hi and welcome to devnet,
It should yes. However there's something not clear: did you re-run qmake after adding
QT += charts
? -
Good, then next thing to check: do you have the lib files available ? Should be but doesn't hurt to double check.
-
Yes I believe you are right, I think you mean that I should have it as
Yes, that's what I meant.
I have installed Qt 5.7 for VS2013 (32 bit), which includes the source files for QtCharts in the folder <Qt directory>\5.7\msvc2013\include\QtCharts. Is that sufficient?
I'd be more concerned, just like @SGaist, whether you can find the import library (the .lib) file and the actual binary (the .dll). Could you search for them in the appropriate folders?
-
You guys are on to something. Apparently I forgot to include QtCharts.lib/QtChartsd.lib in Properties -> Linker -> Input -> Additional Dependencies. I then also had to copy the QtCharts.dll and QtChartsd.dll to the release and debug folders respectively, and now my program runs. Thanks so much for your help!
-
Aha ! You're using Visual Studio to build your application… That was the big missing piece of the puzzle…
I took you where using Qt Creator.
You shouldn't need to copy the .dlls since your application already worked before.
In any case, glad you found out.
Since you have it working now, please mark the thread as solved using the "Topic Tools" button so that other forum users may know a solution has been found :)