Why do I have Multiple Definitions?
-
wrote on 11 Apr 2018, 08:54 last edited by MasterBlade 4 Nov 2018, 08:54
My code used to be all right, until I merged 2 header files.
I have 'gameplay.cpp' and 'gameplay.h' file. But since there are so many contents in Gameplay, I added another header file (named 'card.h). This new header file contains many classes including functions.
Today I just merged these 2 files but got a lot of 'multiple definition' error.
It seems there's also a definition in moc_gameplay.o I don't even know what this file is.I'm sorry I can't paste my code here since it's too long. But I'll try to answer all your questions. There's nothing confidential about the game :)
C:\Users\mfdsr\Documents\MasterZMDJ\gameplay.h:127: error: multiple definition of `MCard::CardInitialization()'
C:\Users\mfdsr\Documents\MasterZMDJ\gameplay.h:127: first defined here
C:\Users\mfdsr\Documents\build-MasterZMDJ-Desktop_Qt_5_10_1_MinGW_32bit-Debug\debug\moc_gameplay.o:-1: In function `ZN5MCardD1Ev':
-
wrote on 11 Apr 2018, 08:54 last edited by
-
wrote on 12 Apr 2018, 01:40 last edited by
@VRonin said in Why do I have Multiple Definitions?:
Thanks for your reply. Actually I used a include guard like this.
#ifndef GAMEPLAY_H
#define GAMEPLAY_HI also tried to disable that include command and everything related to this file in the main window, still I have multiple definition problem.
And through the error log, I found that the file is conflict with itself. All errors come from gameplay.h gameplay.o moc_gameplay.cpp gameplay.o
-
@VRonin said in Why do I have Multiple Definitions?:
Thanks for your reply. Actually I used a include guard like this.
#ifndef GAMEPLAY_H
#define GAMEPLAY_HI also tried to disable that include command and everything related to this file in the main window, still I have multiple definition problem.
And through the error log, I found that the file is conflict with itself. All errors come from gameplay.h gameplay.o moc_gameplay.cpp gameplay.o
@MasterBlade
do a complete clean, preferably delete your shadow build folder, rerun qmake and recompile.Let's see if that fixes it.
-
@MasterBlade
do a complete clean, preferably delete your shadow build folder, rerun qmake and recompile.Let's see if that fixes it.
wrote on 12 Apr 2018, 06:34 last edited by@J.Hilk said in Why do I have Multiple Definitions?:
@MasterBlade
do a complete clean, preferably delete your shadow build folder, rerun qmake and recompile.Let's see if that fixes it.
Sorry I'm new to qt. What is 'shadow build folder'? Does qmake mean 'Build All' in qt Creator?
-
@J.Hilk said in Why do I have Multiple Definitions?:
@MasterBlade
do a complete clean, preferably delete your shadow build folder, rerun qmake and recompile.Let's see if that fixes it.
Sorry I'm new to qt. What is 'shadow build folder'? Does qmake mean 'Build All' in qt Creator?
@MasterBlade
you'll finde the shadow build folder path in your project settings.
Its a folder where all temporary files are created during the compile process and your executable will end up in -
@J.Hilk said in Why do I have Multiple Definitions?:
@MasterBlade
do a complete clean, preferably delete your shadow build folder, rerun qmake and recompile.Let's see if that fixes it.
Sorry I'm new to qt. What is 'shadow build folder'? Does qmake mean 'Build All' in qt Creator?
-
@MasterBlade
you'll finde the shadow build folder path in your project settings.
Its a folder where all temporary files are created during the compile process and your executable will end up inwrote on 12 Apr 2018, 07:19 last edited by MasterBlade 4 Dec 2018, 07:28 -
Lifetime Qt Championwrote on 12 Apr 2018, 07:48 last edited by mrjj 4 Dec 2018, 08:16
hi
the link opens an image of the link :)
Made me go ehh for for a moment.
https://files.fm/u/wh4n4f4aupdate:
the rar file is empty for me.? -
wrote on 12 Apr 2018, 08:11 last edited by
Do you have non-inline methods defined in the .h file? if so move them to the cpp file
-
hi
the link opens an image of the link :)
Made me go ehh for for a moment.
https://files.fm/u/wh4n4f4aupdate:
the rar file is empty for me.?wrote on 12 Apr 2018, 09:32 last edited by MasterBlade 4 Dec 2018, 09:38@mrjj said in Why do I have Multiple Definitions?:
hi
the link opens an image of the link :)
Made me go ehh for for a moment.update:
the rar file is empty for me.?Yeah, I also can't put links here. The page says it's an ad. ('Post content was flagged as spam by Akismet.com') Maybe you have a higher privilege than me :)
You can try this link. https://ufile.io/m53r2
-
wrote on 12 Apr 2018, 09:52 last edited by
@VRonin said in Why do I have Multiple Definitions?:
Do you have non-inline methods defined in the .h file? if so move them to the cpp file
.h file has only classes. There are some functions in the classes of course. Some functions are lengthy and cannot be set as inline. Should I define them in the .cpp file?
-
@VRonin said in Why do I have Multiple Definitions?:
Do you have non-inline methods defined in the .h file? if so move them to the cpp file
.h file has only classes. There are some functions in the classes of course. Some functions are lengthy and cannot be set as inline. Should I define them in the .cpp file?
wrote on 12 Apr 2018, 09:54 last edited by@MasterBlade said in Why do I have Multiple Definitions?:
Should I define them in the .cpp file?
Yes
-
@MasterBlade said in Why do I have Multiple Definitions?:
Should I define them in the .cpp file?
Yes
wrote on 13 Apr 2018, 08:26 last edited by@VRonin said in Why do I have Multiple Definitions?:
@MasterBlade said in Why do I have Multiple Definitions?:
Should I define them in the .cpp file?
Yes
Wow that did solve my problem. Many Many Thanks!!!!!!
1/14