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. error: LNK2019: unresolved external symbol " [QBarSet] [clean + qmake + rebuild don't fix the problem]

error: LNK2019: unresolved external symbol " [QBarSet] [clean + qmake + rebuild don't fix the problem]

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 663 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.
  • J Offline
    J Offline
    Josz
    wrote on last edited by Josz
    #1
    note: 
    clean + qmake + rebuild don't fix the problem
    I use msvc2015 32 bits
    

    Hi community,
    I’m trying to create a class to insert a bar chart into MainWindow, but in the moment that I try to use a QBarSet pointer, i obtain from compiler the error below:

    mybars.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QtCharts::QBarSet::QBarSet(class QString,class QObject *)" (__imp_??0QBarSet@QtCharts@@QAE@VQString@@PAVQObject@@@Z) referenced in function "public: __thiscall myBars::myBars(void)" (??0myBars@@QAE@XZ)
    
    mybars.obj:-1: error: LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall myBars::metaObject(void)const " (?metaObject@myBars@@UBEPBUQMetaObject@@XZ)
    
    debug\my_HorBarras_v01.exe:-1: error: LNK1120: 9 unresolved externals
    
    

    Please, could someone explain me why I obtain this issue and how to fix it?
    Thanks in advance

    here are my codes

    mybars.h

    #ifndef MYBARS_H
    #define MYBARS_H
    #include <QtWidgets/QApplication>
    #include <QtWidgets/QMainWindow>
    #include <QtCharts/QChartView>
    #include <QtCharts/QBarSeries>
    #include <QtCharts/QBarSet>
    #include <QtCharts/QLegend>
    #include <QtCharts/QBarCategoryAxis>
    #include <QtCharts/QHorizontalStackedBarSeries>
    
    QT_CHARTS_USE_NAMESPACE
    class myBars
    {
    public:
        myBars();
        ~myBars();
    
    private:
     QBarSet *set0;
    };
    
    #endif // MYBARS_H
    

    mybars.cpp

    #include "mybars.h"
    myBars::myBars()
    {
     set0= new QBarSet("my");
      *set0 << 1 << 10;
    }
    
    myBars::~myBars()
    {
       delete set0;
    }
    

    mainwindow.h

    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    #include <mybars.h>
    namespace Ui {
    class MainWindow;
    }
    
    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        explicit MainWindow(QWidget *parent = nullptr);
        ~MainWindow();
    
    private:
        Ui::MainWindow *ui;
        myBars *bars;
    };
    
    #endif // MAINWINDOW_H
    

    mywindow.cpp

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    
    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent), ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
        setFixedSize(1024,768);
        bars = new myBars;
    }
    
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    
    
    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Do you also link against the QtCharts module? https://doc.qt.io/qt-5.11/qtcharts-index.html

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      4
      • J Offline
        J Offline
        Josz
        wrote on last edited by
        #3

        Thank you very much!!!
        That was!!

        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