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

LNK 2019 Error



  • Hello again, i have a Problem with one of my classes. When i try to compile i get the LNK2019 Error and i cant find the casue.

    my class Looks like:
    #ifndef DATABLOCKLOADER_H
    #define DATABLOCKLOADER_H

    #include <QFile>
    #include <QTreeView>
    #include "TreeModel.h"
    #include "ProjectObjects/TreeItem.h"

    class DataBlockLoader
    {
    public:
    DataBlockLoader(QTreeView *p_treeView, TreeItem *p_item, TreeModel *p_model);

    void load(QFile *p_file);
    void ArrayAnlegen(QFile *p_file, QString p_ZeilenInhalt, int p_tiefe);
    void StructAnlegen(QFile *p_file, QString p_ZeilenInhalt, int p_tiefe);
    void UDTAnlegen(QString p_filePath, QString p_ZeilenInhalt, int p_Tiefe);
    

    private:

    QTreeView *m_treeView;
    TreeModel *m_model;
    TreeItem *m_parentPointer[99];
    QRegularExpression *m_Datentypen;
    

    };

    #endif // DATABLOCKLOADER_H

    I include it in another calss with:
    #include "ProjectObjects/Devices/Siemens/CPU_S71500/DataBlockLoader.h"

    and then create an object of it with:
    DataBlockLoader *Import = new DataBlockLoader(m_treeView, m_Item, m_model);

    and that is the line causing the error. Someone got an idea? Or you Need more Information of surrounding Code?

    complete Error is here:
    DataBlockView_S71500new.obj:-1: Fehler: LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: __thiscall DataBlockLoader::DataBlockLoader(class QTreeView *,class TreeItem *,class TreeModel *)" (??0DataBlockLoader@@QAE@PAVQTreeView@@PAVTreeItem@@PAVTreeModel@@@Z)" in Funktion ""private: void __thiscall DataBlockView_S71500new::sl_import(void)" (?sl_import@DataBlockView_S71500new@@AAEXXZ)".

    PS:
    The constructo was missing:
    DataBlockLoader::DataBlockLoader(QTreeView *p_treeView, TreeItem *p_item, TreeModel *p_model)
    {
    m_treeView = p_treeView;
    m_model = p_model;

    m_Datentypen = new QRegularExpression;
    m_Datentypen->setPattern(("(Array|Bool|Byte|Char|Int|String|Struct)"));
    
    m_parentPointer[1] = p_item;
    

    }



  • No i said that i little bit unclear, i just meant as information for you the constructor was missing. But it is solved now. I had to delete the QT and c++ build folder, then i just cleaned, run Remake and rebuild, then it worked. My experience now says, that LNK error is not a syntax problem in 99% of all cases .

    "solved"


  • Moderators

    @meikelneit
    did you already do the following?

    • clean
    • rerun qmake
    • rebuild

    If yes or that doesn't solve your issue are you sure that the cpp file implementing the type is added to your .pro file?



  • yeah i did that before.
    clean
    run Remake
    rebuild

    how can i proof if the pro file has that cpp implemented?



  • Ok i found out, but it is inside the .pro
    ProjectObjects/Devices/Siemens/CPU_S71500/DataBlockLoader.cpp and .h


  • Lifetime Qt Champion

    @meikelneit said in LNK 2019 Error:

    The constructo was missing:

    So, is it solved now?



  • No i said that i little bit unclear, i just meant as information for you the constructor was missing. But it is solved now. I had to delete the QT and c++ build folder, then i just cleaned, run Remake and rebuild, then it worked. My experience now says, that LNK error is not a syntax problem in 99% of all cases .

    "solved"


Log in to reply