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. QString compilation error
Forum Updated to NodeBB v4.3 + New Features

QString compilation error

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 6 Posters 1.6k 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.
  • S Offline
    S Offline
    sulkingpotato
    wrote on last edited by
    #1

    In my project (done in Qt Creator), when I attempt to build, I get the issue "'redefinition of class QString'", followed by 800 other issues. Apparently line

    212: class Q_CORE_EXPORT QString

    is causing the problem, but that can't be right, since the project ran just fine when I first initialized it as a Widget Application.

    But all I've been doing is editing my db_init.h file with the implementation of some functions that initialize the database with some data.

    Has anyone run into this message before? I'm not familiar with how the build process in Qt Creator works, so I'm not sure what I can do to address it. It's also been a while since I last coded in C++.

    aha_1980A A JonBJ 3 Replies Last reply
    0
    • S sulkingpotato

      In my project (done in Qt Creator), when I attempt to build, I get the issue "'redefinition of class QString'", followed by 800 other issues. Apparently line

      212: class Q_CORE_EXPORT QString

      is causing the problem, but that can't be right, since the project ran just fine when I first initialized it as a Widget Application.

      But all I've been doing is editing my db_init.h file with the implementation of some functions that initialize the database with some data.

      Has anyone run into this message before? I'm not familiar with how the build process in Qt Creator works, so I'm not sure what I can do to address it. It's also been a while since I last coded in C++.

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

      Hi @sulkingpotato, welcome to the forums.

      in this case I think it would be best to have your complete project uploaded somewhere (Github?), or at least the file that is causing the error.

      It's also been a while since I last coded in C++.

      Indeed, Qt is just C++, so if you run into problems you must solve them with your C++ foo :)

      Qt has to stay free or it will die.

      1 Reply Last reply
      0
      • S sulkingpotato

        In my project (done in Qt Creator), when I attempt to build, I get the issue "'redefinition of class QString'", followed by 800 other issues. Apparently line

        212: class Q_CORE_EXPORT QString

        is causing the problem, but that can't be right, since the project ran just fine when I first initialized it as a Widget Application.

        But all I've been doing is editing my db_init.h file with the implementation of some functions that initialize the database with some data.

        Has anyone run into this message before? I'm not familiar with how the build process in Qt Creator works, so I'm not sure what I can do to address it. It's also been a while since I last coded in C++.

        A Offline
        A Offline
        ambershark
        wrote on last edited by
        #3

        @sulkingpotato First if you feel it isn't a problem you created, try just cleaning and rebuilding. This fixes a lot of these "it just popped up" type of errors.

        If that doesn't help, give us the build log to take a look at for starters.

        My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

        1 Reply Last reply
        0
        • S sulkingpotato

          In my project (done in Qt Creator), when I attempt to build, I get the issue "'redefinition of class QString'", followed by 800 other issues. Apparently line

          212: class Q_CORE_EXPORT QString

          is causing the problem, but that can't be right, since the project ran just fine when I first initialized it as a Widget Application.

          But all I've been doing is editing my db_init.h file with the implementation of some functions that initialize the database with some data.

          Has anyone run into this message before? I'm not familiar with how the build process in Qt Creator works, so I'm not sure what I can do to address it. It's also been a while since I last coded in C++.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @sulkingpotato You have a wonderful forum name... :)

          1 Reply Last reply
          0
          • VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by
            #5

            Did you forget an include guard?

            "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

            1 Reply Last reply
            1
            • S Offline
              S Offline
              sulkingpotato
              wrote on last edited by
              #6

              I think something happened to my installation of Qt Creator, since I used to be able to run new projects. This problem happens when I make a new Qt Console Application and when I make a new Qt Widgets Application, choosing only the defaults. When I try to build and run these freshly generated projects, I get the following compiler log, even after cleaning and rebuilding:

              https://gist.github.com/sulkingpotato/506fe0364f4949224ecc46d455fdcac8

              1 Reply Last reply
              0
              • Christian EhrlicherC Offline
                Christian EhrlicherC Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #7

                You must have a typedef or something which defines QLatin1String to QString. Maybe you have some Qt4 includes in your include path.
                In line 91 QLatin1String is defined, in line 212 QString. Maybe you simply forgot a semicolon at the end of your class definition or something like this.

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                1 Reply Last reply
                2
                • S Offline
                  S Offline
                  sulkingpotato
                  wrote on last edited by
                  #8

                  I reinstalled Qt Creator with an older version of Qt. The projects now compile with no errors.

                  Thanks for all the suggestions!

                  1 Reply Last reply
                  0

                  • Login

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