Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Why do I have Multiple Definitions?
Qt 6.11 is out! See what's new in the release blog

Why do I have Multiple Definitions?

Scheduled Pinned Locked Moved Solved General and Desktop
14 Posts 5 Posters 13.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M MasterBlade

    @VRonin said in Why do I have Multiple Definitions?:

    https://en.wikipedia.org/wiki/Include_guard

    Thanks for your reply. Actually I used a include guard like this.

    #ifndef GAMEPLAY_H
    #define GAMEPLAY_H

    I 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

    J.HilkJ Offline
    J.HilkJ Offline
    J.Hilk
    Moderators
    wrote on last edited by
    #4

    @MasterBlade
    do a complete clean, preferably delete your shadow build folder, rerun qmake and recompile.

    Let's see if that fixes it.


    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


    Q: What's that?
    A: It's blue light.
    Q: What does it do?
    A: It turns blue.

    M 1 Reply Last reply
    0
    • J.HilkJ J.Hilk

      @MasterBlade
      do a complete clean, preferably delete your shadow build folder, rerun qmake and recompile.

      Let's see if that fixes it.

      M Offline
      M Offline
      MasterBlade
      wrote on last edited by
      #5

      @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.HilkJ aha_1980A 2 Replies Last reply
      0
      • M MasterBlade

        @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.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #6

        @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

        0_1523515178384_f8f7964a-2097-4735-9e22-38ec9b1b4fdd-image.png


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        M 1 Reply Last reply
        1
        • M MasterBlade

          @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?

          aha_1980A Offline
          aha_1980A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on last edited by
          #7

          @MasterBlade

          Build > Run Qmake

          after that, do:

          Build > Rebuild

          Qt has to stay free or it will die.

          1 Reply Last reply
          0
          • J.HilkJ J.Hilk

            @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

            0_1523515178384_f8f7964a-2097-4735-9e22-38ec9b1b4fdd-image.png

            M Offline
            M Offline
            MasterBlade
            wrote on last edited by MasterBlade
            #8

            @J.Hilk @aha_1980
            I tried to delete shadow folder ,run qmake, then rubuild all, still the same problem

            I decided to upload the source file. It's fairly simple at this state. I know you experts do a much better job than me.

            I can't upload file here. check this link for file 0_1523518096178_1.png

            1 Reply Last reply
            0
            • mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by mrjj
              #9

              hi
              the link opens an image of the link :)
              Made me go ehh for for a moment.
              https://files.fm/u/wh4n4f4a

              update:
              the rar file is empty for me.?

              M 1 Reply Last reply
              2
              • VRoninV Offline
                VRoninV Offline
                VRonin
                wrote on last edited by
                #10

                Do you have non-inline methods defined in the .h file? if so move them to the cpp file

                "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                ~Napoleon Bonaparte

                On a crusade to banish setIndexWidget() from the holy land of Qt

                M 1 Reply Last reply
                4
                • mrjjM mrjj

                  hi
                  the link opens an image of the link :)
                  Made me go ehh for for a moment.
                  https://files.fm/u/wh4n4f4a

                  update:
                  the rar file is empty for me.?

                  M Offline
                  M Offline
                  MasterBlade
                  wrote on last edited by MasterBlade
                  #11

                  @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

                  The rar file looks alright to me. It's 205 KB.
                  0_1523525477714_2.PNG

                  1 Reply Last reply
                  0
                  • VRoninV VRonin

                    Do you have non-inline methods defined in the .h file? if so move them to the cpp file

                    M Offline
                    M Offline
                    MasterBlade
                    wrote on last edited by
                    #12

                    @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?

                    VRoninV 1 Reply Last reply
                    0
                    • M MasterBlade

                      @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?

                      VRoninV Offline
                      VRoninV Offline
                      VRonin
                      wrote on last edited by
                      #13

                      @MasterBlade said in Why do I have Multiple Definitions?:

                      Should I define them in the .cpp file?

                      Yes

                      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                      ~Napoleon Bonaparte

                      On a crusade to banish setIndexWidget() from the holy land of Qt

                      M 1 Reply Last reply
                      4
                      • VRoninV VRonin

                        @MasterBlade said in Why do I have Multiple Definitions?:

                        Should I define them in the .cpp file?

                        Yes

                        M Offline
                        M Offline
                        MasterBlade
                        wrote on last edited by
                        #14

                        @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 Reply Last reply
                        1

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved