Windows Linking errors metaObject, qt_metacast and qt_metacall
-
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 -
-
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: