Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QtCharts causing linking errors (LNK2019)
QtWS25 Last Chance

QtCharts causing linking errors (LNK2019)

Scheduled Pinned Locked Moved Solved General and Desktop
qtchartslnk2019lnk2001qbarset
11 Posts 4 Posters 10.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A ashkan849
    3 Aug 2016, 18:55

    Hi, I've been trying to use QtCharts for Qt 5.7 for VS 2013, 32 bit. However, whenever I try to use a QtChart object, for example QHorizontalStackedBarSeries, it results in numerous linking errors. Here is an example of a cpp file where this occurs:

    #include <qtcharts/qchartview>
    #include <qtcharts/qbarseries>
    #include <qtcharts/qbarset>
    #include <qtcharts/qlegend>
    #include <qtcharts/qbarcategoryaxis>
    #include <qtcharts/qhorizontalstackedbarseries>
    
    using namespace std;
    using namespace QtCharts;
    
    ClassName::ClassName() { }
    
    ClassName::FunctionName()
    { 
        QHorizontalStackedBarSeries *series = new QHorizontalStackedBarSeries();
    }
    

    This results in the following errors:

    Error	2	error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QtCharts::QHorizontalStackedBarSeries::QHorizontalStackedBarSeries(class QObject *)" (__imp_??0QHorizontalStackedBarSeries@QtCharts@@QAE@PAVQObject@@@Z) referenced in function "public: __thiscall ClassName::FunctionName(class QWidget *)" (??0ClassName@@QAE@PAVQWidget@@@Z)	ProjectName\ClassName.obj	ProjectName
    
    Error	3	error MSB6006: "link.exe" exited with code 1120.	C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targets	607	5	ProjectName
    
    Error	4	error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall QtCharts::QHorizontalStackedBarSeries::~QHorizontalStackedBarSeries(void)" (__imp_??1QHorizontalStackedBarSeries@QtCharts@@UAE@XZ) referenced in function "public: virtual void * __thiscall QtCharts::QHorizontalStackedBarSeries::`scalar deleting destructor'(unsigned int)" (??_GQHorizontalStackedBarSeries@QtCharts@@UAEPAXI@Z)	ProjectName\ClassName.obj	ProjectName
    
    Error	5	error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall QtCharts::QHorizontalStackedBarSeries::metaObject(void)const " (?metaObject@QHorizontalStackedBarSeries@QtCharts@@UBEPBUQMetaObject@@XZ)	ProjectName\ClassName.obj	PrjoectName
    
    Error	6	error LNK2001: unresolved external symbol "public: virtual int __thiscall QtCharts::QHorizontalStackedBarSeries::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@QHorizontalStackedBarSeries@QtCharts@@UAEHW4Call@QMetaObject@@HPAPAX@Z)	ProjectName\ClassName.obj	ProjectName
    
    Error	7	error LNK2001: unresolved external symbol "public: virtual void * __thiscall QtCharts::QHorizontalStackedBarSeries::qt_metacast(char const *)" (?qt_metacast@QHorizontalStackedBarSeries@QtCharts@@UAEPAXPBD@Z)	ProjectName\ClassName.obj	ProjectName
    
    Error	8	error LNK2001: unresolved external symbol "public: virtual enum QtCharts::QAbstractSeries::SeriesType __thiscall QtCharts::QHorizontalStackedBarSeries::type(void)const " (?type@QHorizontalStackedBarSeries@QtCharts@@UBE?AW4SeriesType@QAbstractSeries@2@XZ)	ProjectName\ClassName.obj	ProjectName
    
    Error	9	error LNK1120: 6 unresolved externals	ProjectName\ClassName.obj	ProjectName
    

    This will also happen with other QtChart objects, such as QBarSet. Would anyone have an idea what could be causing this? I've already tried:
    -cleaning the project
    -in QtLauncher, cleaning the project and running QMake
    -adding "QT += charts" in the .pro file

    Any input would be appreciated, thanks!

    K Offline
    K Offline
    kshegunov
    Moderators
    wrote on 3 Aug 2016, 19:36 last edited by
    #2

    @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.

    Read and abide by the Qt Code of Conduct

    1 Reply Last reply
    0
    • A Offline
      A Offline
      ashkan849
      wrote on 4 Aug 2016, 14:24 last edited by
      #3

      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?

      K 1 Reply Last reply 5 Aug 2016, 04:12
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 4 Aug 2016, 20:45 last edited by
        #4

        Hi and welcome to devnet,

        It should yes. However there's something not clear: did you re-run qmake after adding QT += charts ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • A Offline
          A Offline
          ashkan849
          wrote on 4 Aug 2016, 22:39 last edited by
          #5

          Thanks! And yes, I did run qmake after adding QT += charts

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 4 Aug 2016, 22:45 last edited by
            #6

            Good, then next thing to check: do you have the lib files available ? Should be but doesn't hurt to double check.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • A ashkan849
              4 Aug 2016, 14:24

              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?

              K Offline
              K Offline
              kshegunov
              Moderators
              wrote on 5 Aug 2016, 04:12 last edited by
              #7

              @ashkan849

              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?

              Read and abide by the Qt Code of Conduct

              1 Reply Last reply
              0
              • A Offline
                A Offline
                ashkan849
                wrote on 5 Aug 2016, 20:27 last edited by
                #8

                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!

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 5 Aug 2016, 20:35 last edited by
                  #9

                  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 :)

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  1
                  • A Offline
                    A Offline
                    ashkan849
                    wrote on 8 Aug 2016, 14:03 last edited by
                    #10

                    Will do. Thanks again for your help!

                    1 Reply Last reply
                    0
                    • N Offline
                      N Offline
                      NewBird
                      wrote on 31 Aug 2017, 03:53 last edited by
                      #11

                      Thanks a lot! solve my problem, it is really easy to foget that!

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved