Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QString compilation error
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++.
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 :)
@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.
JonB last edited by
@sulkingpotato You have a wonderful forum name... :)
VRonin last edited by
Did you forget an include guard?
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:
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.
I reinstalled Qt Creator with an older version of Qt. The projects now compile with no errors.
Thanks for all the suggestions!