Dolphin, the GameCube and Wii emulator - Forums
Linker errors when trying to compile - Printable Version

+- Dolphin, the GameCube and Wii emulator - Forums (https://forums.dolphin-emu.org)
+-- Forum: Dolphin Emulator Discussion and Support (https://forums.dolphin-emu.org/Forum-dolphin-emulator-discussion-and-support)
+--- Forum: Development Discussion (https://forums.dolphin-emu.org/Forum-development-discussion)
+--- Thread: Linker errors when trying to compile (/Thread-linker-errors-when-trying-to-compile)



Linker errors when trying to compile - LittleCoaks - 09-09-2021

I've been stuck on this problem for a while now. I'm building with Visual Studio 2019. I've built fine before, but even since i tried adding 4 different files to the build, 2 headers and 2 cpp files, i get 8 LNK2001 errors followed by LNK1180 fatal error. I already added the files to CMakeLists.txt but i am still having issues. Any help on this is appreciated. Below is the log from Visual Studio

Code:
3>LocalPlayersWidget.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __cdecl LocalPlayersWidget::metaObject(void)const " (?metaObject@LocalPlayersWidget@@UEBAPEBUQMetaObject@@XZ)
3>LocalPlayersWidget.obj : error LNK2001: unresolved external symbol "public: virtual void * __cdecl LocalPlayersWidget::qt_metacast(char const *)" (?qt_metacast@LocalPlayersWidget@@UEAAPEAXPEBD@Z)
3>LocalPlayersWidget.obj : error LNK2001: unresolved external symbol "public: virtual int __cdecl LocalPlayersWidget::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@LocalPlayersWidget@@UEAAHW4Call@QMetaObject@@HPEAPEAX@Z)
3>LocalPlayersWidget.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const LocalPlayersWidget::staticMetaObject" (?staticMetaObject@LocalPlayersWidget@@2UQMetaObject@@B)
3>LocalPlayersWindow.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __cdecl LocalPlayersWindow::metaObject(void)const " (?metaObject@LocalPlayersWindow@@UEBAPEBUQMetaObject@@XZ)
3>LocalPlayersWindow.obj : error LNK2001: unresolved external symbol "public: virtual void * __cdecl LocalPlayersWindow::qt_metacast(char const *)" (?qt_metacast@LocalPlayersWindow@@UEAAPEAXPEBD@Z)
3>LocalPlayersWindow.obj : error LNK2001: unresolved external symbol "public: virtual int __cdecl LocalPlayersWindow::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@LocalPlayersWindow@@UEAAHW4Call@QMetaObject@@HPEAPEAX@Z)
3>LocalPlayersWindow.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const LocalPlayersWindow::staticMetaObject" (?staticMetaObject@LocalPlayersWindow@@2UQMetaObject@@B)
3>C:\Users\15165\Rio Modding Project\Project Rio\PR official\Build\x64\Release\Project Rio\bin\Project Rio.exe : fatal error LNK1120: 8 unresolved externals
3>Done building project "DolphinQt.vcxproj" -- FAILED.
========== Build: 1 succeeded, 1 failed, 32 up-to-date, 1 skipped ==========



RE: Linker errors when trying to compile - Zopolis4 - 09-09-2021

From what I can see, you might not have added them to DolphinQt.vcxproj file? Could you send a screenshot of the changes listed in the git changes tab?


RE: Linker errors when trying to compile - LittleCoaks - 09-10-2021

(09-09-2021, 04:23 PM)Zopolis4 Wrote: From what I can see, you might not have added them to DolphinQt.vcxproj file? Could you send a screenshot of the changes listed in the git changes tab?

i def didn't do that manually, but it seems like it was done automatically. Here's a screenshot of my git changes. Some of the changes are not relevant to my problem, so i've checked off the changes that relate to the situation (if something's not checked just ignore it)


RE: Linker errors when trying to compile - JosJuice - 09-10-2021

DolphinQt.vcxproj has one section for things that don't need to be ran through moc and one section for things that do. You've most likely used the non-moc section when you needed the moc section. (Visual Studio's ability to automatically add things to the vcxproj files doesn't know about moc and just treats everything as if it doesn't need moc. You'll need to edit the vcxproj file manually.)


RE: Linker errors when trying to compile - LittleCoaks - 09-10-2021

(09-10-2021, 01:13 AM)JosJuice Wrote: DolphinQt.vcxproj has one section for things that don't need to be ran through moc and one section for things that do. You've most likely used the non-moc section when you needed the moc section. (Visual Studio's ability to automatically add things to the vcxproj files doesn't know about moc and just treats everything as if it doesn't need moc. You'll need to edit the vcxproj file manually.)

This fix worked perfectly, thank you!

I'll document what i did just in case someone else with the same problem reads this thread.
I added two header files which used Q_OBJECT. DolphinQt.vcxproj states on ln203 that if Q_OBJECT is used in the header file then the item type must be set to QtMoc. Visual Studio automatically added my two header files to DolphinQt.vcxproj with the item type ClInclude, so i changed it to QtMoc, saved the file, and then was able to build Dolphin.