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. Windows Linking errors metaObject, qt_metacast and qt_metacall
Forum Updated to NodeBB v4.3 + New Features

Windows Linking errors metaObject, qt_metacast and qt_metacall

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 1 Posters 688 Views 1 Watching
  • 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
    jalway
    wrote on last edited by
    #1

    Hello,

    I'm compiling a QT project for OBS Studio. I'm on Windows 10 and am using Visual Studio 2022, coding with C++.

    The project is here:obs-plugintemplate

    I've added code to the project that implements QT. In their cmake file they allow you to turn on QT. I did this.

    QT is installed by them, but when I compile their code it won't link.

    I get these unresolved errors:

    • 1>test.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __cdecl TestWidget::metaObject(void)const " (?metaObject@TestWidget@@UEBAPEBUQMetaObject@@XZ)

    • 1>test.obj : error LNK2001: unresolved external symbol "public: virtual void * __cdecl TestWidget::qt_metacast(char const *)" (?qt_metacast@TestWidget@@UEAAPEAXPEBD@Z)

    • 1>test.obj : error LNK2001: unresolved external symbol "public: virtual int __cdecl TestWidget::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@TestWidget@@UEAAHW4Call@QMetaObject@@HPEAPEAX@Z)

    • 1>C:\Projects\temp\duanepugh\obs_intro\obs-exprplugin\build_x64\Release\obs-experiment-plugin.dll : fatal error LNK1120: 3 unresolved externals

    Here is what my test.h file contains:

    #include <QtWidgets/QDockWidget>
    #include <QtWidgets/QPushButton>
    #include <QtWidgets/QHBoxLayout>
    #include <QtWidgets/QWidget>
    #include <QtWidgets/QMessageBox>
    
    class TestWidget : public QDockWidget
    {
    	Q_OBJECT
    public:
    	explicit TestWidget(QWidget *parent = nullptr);
    	~TestWidget();
    
    private:
    	void buttonClicked();
    	QWidget *parent = nullptr;
    	QPushButton *button = new QPushButton();
    
    private slots:
    	void ButtonClicked();
    };
    

    And here is my test.cpp file contents:

    #include "test.h"
    
    TestWidget::TestWidget(QWidget *parent) : QDockWidget("My Plugin", parent)
    {
    	this->parent = parent;
    
    	QWidget *widget = new QWidget();
    	this->button->setText("Press Me!");
    	QHBoxLayout *layout = new QHBoxLayout();
    	layout->addWidget(this->button);
    
    	widget->setLayout(layout);
    
    	setWidget(widget);
    
    	setVisible(false);
    	setFloating(true);
    
    	resize(300, 300);
    
    	QObject::connect(button, SIGNAL(clicked()), SLOT(ButtonClicked()));
    }
    
    TestWidget::~TestWidget() 
    {
    }
    
    void TestWidget::ButtonClicked()
    {
    	QMessageBox::information(this, "Info", "You clicked on a box!");
    }
    
    
    

    Any help would be appreciated.

    Thanks!
    ...John

    J 1 Reply Last reply
    0
    • J jalway

      Hello,

      I'm compiling a QT project for OBS Studio. I'm on Windows 10 and am using Visual Studio 2022, coding with C++.

      The project is here:obs-plugintemplate

      I've added code to the project that implements QT. In their cmake file they allow you to turn on QT. I did this.

      QT is installed by them, but when I compile their code it won't link.

      I get these unresolved errors:

      • 1>test.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __cdecl TestWidget::metaObject(void)const " (?metaObject@TestWidget@@UEBAPEBUQMetaObject@@XZ)

      • 1>test.obj : error LNK2001: unresolved external symbol "public: virtual void * __cdecl TestWidget::qt_metacast(char const *)" (?qt_metacast@TestWidget@@UEAAPEAXPEBD@Z)

      • 1>test.obj : error LNK2001: unresolved external symbol "public: virtual int __cdecl TestWidget::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@TestWidget@@UEAAHW4Call@QMetaObject@@HPEAPEAX@Z)

      • 1>C:\Projects\temp\duanepugh\obs_intro\obs-exprplugin\build_x64\Release\obs-experiment-plugin.dll : fatal error LNK1120: 3 unresolved externals

      Here is what my test.h file contains:

      #include <QtWidgets/QDockWidget>
      #include <QtWidgets/QPushButton>
      #include <QtWidgets/QHBoxLayout>
      #include <QtWidgets/QWidget>
      #include <QtWidgets/QMessageBox>
      
      class TestWidget : public QDockWidget
      {
      	Q_OBJECT
      public:
      	explicit TestWidget(QWidget *parent = nullptr);
      	~TestWidget();
      
      private:
      	void buttonClicked();
      	QWidget *parent = nullptr;
      	QPushButton *button = new QPushButton();
      
      private slots:
      	void ButtonClicked();
      };
      

      And here is my test.cpp file contents:

      #include "test.h"
      
      TestWidget::TestWidget(QWidget *parent) : QDockWidget("My Plugin", parent)
      {
      	this->parent = parent;
      
      	QWidget *widget = new QWidget();
      	this->button->setText("Press Me!");
      	QHBoxLayout *layout = new QHBoxLayout();
      	layout->addWidget(this->button);
      
      	widget->setLayout(layout);
      
      	setWidget(widget);
      
      	setVisible(false);
      	setFloating(true);
      
      	resize(300, 300);
      
      	QObject::connect(button, SIGNAL(clicked()), SLOT(ButtonClicked()));
      }
      
      TestWidget::~TestWidget() 
      {
      }
      
      void TestWidget::ButtonClicked()
      {
      	QMessageBox::information(this, "Info", "You clicked on a box!");
      }
      
      
      

      Any help would be appreciated.

      Thanks!
      ...John

      J Offline
      J Offline
      jalway
      wrote on last edited by
      #2

      @jalway

      Should there be a qmake.exe in by qt/bin folder?

      in my qt bin folder I see moc.exe, qlalr.exe, qsb.exe, qtpath.exe, ptpaths6.exe, qvkgen.exe, rcc.exe, tracegen.exe and uic.exe, but I don't see qmake.exe.

      I note that Qt VS Tools in Visual Studio 2022 requires that you find the path to that to connect to the version of QT you have installed, but I don't see qmake.exe there.

      I got that from here:

      Add Qt versions

      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