Unsolved First Qt cmd line app
-
Hi,
I am a C++ developer and wanted to try Qt a bit. Normally using VC++ 2017, so I installed Qt version 5.12 and created a new Qt cmd line app using the creator. However, when creating a simplest class deriving from QObject I get lots of linker errors related to some metaObject classes. It makes very little sense, the whole compile/link/debug process seems quite complicated compared to VisualStudio. I know it is very different but please, could someone help with this? I get the following errors:
02:53:46: Running steps for project FirstConsoleApp...
02:53:46: Starting: "C:\Development\Qt\Qt5.12.0\5.12.0\msvc2017_64\bin\qmake.exe" D:\Development\Qt\FirstConsoleApp\FirstConsoleApp.pro -spec win32-msvc "CONFIG+=qtquickcompiler"
Info: creating stash file D:\Development\Qt\build-FirstConsoleApp-Desktop_Qt_5_12_0_MSVC2017_64bit-Release.qmake.stash
02:53:47: The process "C:\Development\Qt\Qt5.12.0\5.12.0\msvc2017_64\bin\qmake.exe" exited normally.
02:53:47: Starting: "C:\Development\Qt\Qt5.12.0\Tools\QtCreator\bin\jom.exe" -f D:/Development/Qt/build-FirstConsoleApp-Desktop_Qt_5_12_0_MSVC2017_64bit-Release/Makefile qmake_alljom 1.1.2 - empower your cores
02:53:47: The process "C:\Development\Qt\Qt5.12.0\Tools\QtCreator\bin\jom.exe" exited normally.
02:53:47: Starting: "C:\Development\Qt\Qt5.12.0\Tools\QtCreator\bin\jom.exe"
C:\Development\Qt\Qt5.12.0\Tools\QtCreator\bin\jom.exe -f Makefile.Release
cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -O2 -MD -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -EHsc -DUNICODE -D_UNICODE -DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DWIN64 -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_CORE_LIB -DNDEBUG -I..\FirstConsoleApp -I. -IC:\Development\Qt\Qt5.12.0\5.12.0\msvc2017_64\include -IC:\Development\Qt\Qt5.12.0\5.12.0\msvc2017_64\include\QtCore -Irelease -IC:\Development\Qt\Qt5.12.0\5.12.0\msvc2017_64\mkspecs\win32-msvc -Forelease\ @C:\Users\PRZEMY~1\AppData\Local\Temp\main.obj.1784.15.jom
main.cpp
..\FirstConsoleApp\main.cpp(105): warning C4100: 'order': unreferenced formal parameter
..\FirstConsoleApp\main.cpp(30): warning C5046: 'anonymous-namespace'::QOrderCache::metaObject': Symbol involving type with internal linkage not defined ..\FirstConsoleApp\main.cpp(30): warning C5046: '
anonymous-namespace'::QOrderCache::qt_metacast': Symbol involving type with internal linkage not defined
..\FirstConsoleApp\main.cpp(30): warning C5046: 'anonymous-namespace'::QOrderCache::qt_metacall': Symbol involving type with internal linkage not defined ..\FirstConsoleApp\main.cpp(16): warning C5046: '
anonymous-namespace'::QOrder::metaObject': Symbol involving type with internal linkage not defined
..\FirstConsoleApp\main.cpp(16): warning C5046: 'anonymous-namespace'::QOrder::qt_metacast': Symbol involving type with internal linkage not defined ..\FirstConsoleApp\main.cpp(16): warning C5046: '
anonymous-namespace'::QOrder::qt_metacall': Symbol involving type with internal linkage not defined
..\FirstConsoleApp\main.cpp(90): warning C5046: 'anonymous-namespace'::QTradingService::metaObject': Symbol involving type with internal linkage not defined ..\FirstConsoleApp\main.cpp(90): warning C5046: '
anonymous-namespace'::QTradingService::qt_metacast': Symbol involving type with internal linkage not defined
..\FirstConsoleApp\main.cpp(90): warning C5046: 'anonymous-namespace'::QTradingService::qt_metacall': Symbol involving type with internal linkage not defined link /NOLOGO /DYNAMICBASE /NXCOMPAT /INCREMENTAL:NO /SUBSYSTEM:CONSOLE "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST:embed /OUT:release\FirstConsoleApp.exe @C:\Users\PRZEMY~1\AppData\Local\Temp\FirstConsoleApp.exe.1784.2484.jom main.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __cdecl
anonymous namespace'::QOrder::metaObject(void)const " (?metaObject@QOrder@?A0x87dcd2e0@@UEBAPEBUQMetaObject@@XZ)
main.obj : error LNK2001: unresolved external symbol "public: virtual void * __cdeclanonymous namespace'::QOrder::qt_metacast(char const *)" (?qt_metacast@QOrder@?A0x87dcd2e0@@UEAAPEAXPEBD@Z) main.obj : error LNK2001: unresolved external symbol "public: virtual int __cdecl
anonymous namespace'::QOrder::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@QOrder@?A0x87dcd2e0@@UEAAHW4Call@QMetaObject@@HPEAPEAX@Z)
main.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __cdeclanonymous namespace'::QOrderCache::metaObject(void)const " (?metaObject@QOrderCache@?A0x87dcd2e0@@UEBAPEBUQMetaObject@@XZ) main.obj : error LNK2001: unresolved external symbol "public: virtual void * __cdecl
anonymous namespace'::QOrderCache::qt_metacast(char const *)" (?qt_metacast@QOrderCache@?A0x87dcd2e0@@UEAAPEAXPEBD@Z)
main.obj : error LNK2001: unresolved external symbol "public: virtual int __cdeclanonymous namespace'::QOrderCache::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@QOrderCache@?A0x87dcd2e0@@UEAAHW4Call@QMetaObject@@HPEAPEAX@Z) main.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __cdecl
anonymous namespace'::QTradingService::metaObject(void)const " (?metaObject@QTradingService@?A0x87dcd2e0@@UEBAPEBUQMetaObject@@XZ)
main.obj : error LNK2001: unresolved external symbol "public: virtual void * __cdeclanonymous namespace'::QTradingService::qt_metacast(char const *)" (?qt_metacast@QTradingService@?A0x87dcd2e0@@UEAAPEAXPEBD@Z) main.obj : error LNK2001: unresolved external symbol "public: virtual int __cdecl
anonymous namespace'::QTradingService::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@QTradingService@?A0x87dcd2e0@@UEAAHW4Call@QMetaObject@@HPEAPEAX@Z)
release\FirstConsoleApp.exe : fatal error LNK1120: 9 unresolved externals
jom: D:\Development\Qt\build-FirstConsoleApp-Desktop_Qt_5_12_0_MSVC2017_64bit-Release\Makefile.Release [release\FirstConsoleApp.exe] Error 1120
jom: D:\Development\Qt\build-FirstConsoleApp-Desktop_Qt_5_12_0_MSVC2017_64bit-Release\Makefile [release] Error 2
02:53:50: The process "C:\Development\Qt\Qt5.12.0\Tools\QtCreator\bin\jom.exe" exited with code 2.
Error while building/deploying project FirstConsoleApp (kit: Desktop Qt 5.12.0 MSVC2017 64bit)
When executing step "Make"
02:53:50: Elapsed time: 00:04.I think I have set up the variables correctly in the Kits section. Not really sure what is wrong.
Thanks a lot for any hints. -
Hi and welcome to devnet,
Can you show your main.cpp file ?
Also did you put your QObject based class in your main.cpp file ?
If so, did you also
#include "main.moc"
? at the bottom of yourmain.cpp
file ?This last one is mandatory if you didn't declare your QObject derived class in its own header.
-
Did you create default project and no modifications from you. Does this simple project work ?