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. Build error. Unresolved external symbol
Qt 6.11 is out! See what's new in the release blog

Build error. Unresolved external symbol

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 389 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 Offline
    A Offline
    aravmadd
    wrote on last edited by aravmadd
    #1

    This is what is output of the error

    moc_widget.obj:-1: error: LNK2019: unresolved external symbol "private: void __cdecl Widget::setValue(int)" (?setValue@Widget@@AEAAXH@Z) referenced in function "private: static void __cdecl Widget::qt_static_metacall(class QObject *,enum QMetaObject::Call,int,void * *)" (?qt_static_metacall@Widget@@CAXPEAVQObject@@W4Call@QMetaObject@@HPEAPEAX@Z)
    

    I am trying to implement some custom slots and signals for my gui.

    This is how my header looks like

    QT_BEGIN_NAMESPACE
    namespace Ui { class Widget; }
    QT_END_NAMESPACE
    
    class Widget : public QWidget
    {
        Q_OBJECT
    
    public:
        Widget(QWidget *parent = nullptr);
        ~Widget();
    
    private slots:
        void on_pushButton_clicked();
        void setValue(int value);
    
    signals:
        void valueChanged(int newValue);
    
    
    private:
        Ui::Widget *ui;
    
        void init_gui();
        int normalize(int iterations, int curriternum);
        int m_value;
    
    };
    #endif // WIDGET_H
    

    If i remove setValue from private slot it is building properly but if i include that its not build ing.

    My pro file

    QT       += core gui
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    #ONFIG += c++11
    
    # You can make your code fail to compile if it uses deprecated APIs.
    # In order to do so, uncomment the following line.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    
    
    INCLUDEPATH += ..\dependencies\eigen\include\eigen3\Eigen
    
    LIBS += -lwsock32
    LIBS += -lws2_32
    LIBS +=  -lkernel32 -lkernel32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32
    
    SOURCES += \
        main.cpp \
        widget.cpp
    
    HEADERS += \
        widget.h
    
    FORMS += \
        widget.ui
    
    # Default rules for deployment.
    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target
    
    

    As per some posts in stack and qt forum few suggested to run qmake and i did that. When building the error still remains?

    JonBJ 1 Reply Last reply
    0
    • A aravmadd

      This is what is output of the error

      moc_widget.obj:-1: error: LNK2019: unresolved external symbol "private: void __cdecl Widget::setValue(int)" (?setValue@Widget@@AEAAXH@Z) referenced in function "private: static void __cdecl Widget::qt_static_metacall(class QObject *,enum QMetaObject::Call,int,void * *)" (?qt_static_metacall@Widget@@CAXPEAVQObject@@W4Call@QMetaObject@@HPEAPEAX@Z)
      

      I am trying to implement some custom slots and signals for my gui.

      This is how my header looks like

      QT_BEGIN_NAMESPACE
      namespace Ui { class Widget; }
      QT_END_NAMESPACE
      
      class Widget : public QWidget
      {
          Q_OBJECT
      
      public:
          Widget(QWidget *parent = nullptr);
          ~Widget();
      
      private slots:
          void on_pushButton_clicked();
          void setValue(int value);
      
      signals:
          void valueChanged(int newValue);
      
      
      private:
          Ui::Widget *ui;
      
          void init_gui();
          int normalize(int iterations, int curriternum);
          int m_value;
      
      };
      #endif // WIDGET_H
      

      If i remove setValue from private slot it is building properly but if i include that its not build ing.

      My pro file

      QT       += core gui
      
      greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
      
      #ONFIG += c++11
      
      # You can make your code fail to compile if it uses deprecated APIs.
      # In order to do so, uncomment the following line.
      #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
      
      
      INCLUDEPATH += ..\dependencies\eigen\include\eigen3\Eigen
      
      LIBS += -lwsock32
      LIBS += -lws2_32
      LIBS +=  -lkernel32 -lkernel32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32
      
      SOURCES += \
          main.cpp \
          widget.cpp
      
      HEADERS += \
          widget.h
      
      FORMS += \
          widget.ui
      
      # Default rules for deployment.
      qnx: target.path = /tmp/$${TARGET}/bin
      else: unix:!android: target.path = /opt/$${TARGET}/bin
      !isEmpty(target.path): INSTALLS += target
      
      

      As per some posts in stack and qt forum few suggested to run qmake and i did that. When building the error still remains?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @aravmadd
      You have declared a private slot setValue() but do not seem to have actually defined the method, hence the link error?

      1 Reply Last reply
      3

      • Login

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