Qt/C++: 'undefined reference to __imp__ZN5Enemy16staticMetaObjectE' when building project on Windows with MinGW

101 Views Asked by At

It is my first post here so please ask for any extra info you need! I have to make this game in Qt with a given source code to start from: world.h & world.cpp Given code class example:

Now when I build the project I get this error for every class & its functions defined in these files (29 similar errors):

ERROR: :-1: error: debug/moc_world.o: in function Enemy::metaObject() const': team-c4-fa\build-PanicGame-Desktop_Qt_6_5_3_MinGW_64_bit-Debug\debug\moc_world.cpp:129: error: **undefined reference to __imp__ZN5Enemy16staticMetaObjectE'** :-1: error: debug/moc_world.o: in function Enemy::dead()': team-c4-fa\build-PanicGame-Desktop_Qt_6_5_3_MinGW_64_bit-Debug\debug\moc_world.cpp:162: error: undefined reference to __imp__ZN5Enemy16staticMetaObjectE' :-1: error: debug/moc_world.o: in function PEnemy::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)': team-c4-fa\build-PanicGame-Desktop_Qt_6_5_3_MinGW_64_bit-Debug\debug\moc_world.cpp:257: error: undefined reference to __imp__ZN6PEnemy6poisonEv'errors

I suspect that this error has something to do with the way my build directory is setup, it gives me the warning of : “The build directory should be at the same level as the source directory.” I can’t seem to change this by restructuring the hierarchy.warning build directory

EXTRA: I have two warnings and an error before all these similar errors: team-c4-fa\build-PanicGame-Desktop_Qt_6_5_3_MinGW_64_bit-Debug\Makefile.Debug:1494: warning: overriding recipe for target 'debug/world.o' team-c4-fa\build-PanicGame-Desktop_Qt_6_5_3_MinGW_64_bit-Debug\Makefile.Debug:1491: warning: ignoring old recipe for target 'debug/world.o' :-1: error: debug/game.o: in function `Game::loadWorld(QString)':

First I thought something was wrong with the "linking" (that was what chat gpt said). So I tried recreating the troubled classes & cleaning the project and rebuilding it, not sure what exactly I was doing

0

There are 0 best solutions below