mercredi 22 février 2017

Compiling a Qt application with MingW and C++11

I am pretty new to C/C++ development under Windows but I have a lot of experience on Linux. I have an existing Qt application that uses with QMake and QtCreator and builds fine with MSVC2013 but fails to build using MingW.

The project is currently using:

  • QMake
  • QtCreator
  • Microsofts compiler from Visual Studio 2013 (msvc2013)
  • C++11 Standard
  • A 64bit build
  • Qt 5.3

When I build with MSVC then the build works, but when I use MingW I get a lot of syntax errors such as:

Redefinition of 'QString foobar'

or

conflicting declaration of 'Foo::Bar'

There are hundreds of these errors. Under MingW I am using G++ 5.3 which should be perfectly capable of compiling C++11, so I am not sure where all these issues are coming from.

The reason I am trying to get the MinGW to work, is so that I can switch to CLion. So once the MinGW build works in QtCreator I will setup a CMake build and then possbily drop QMake.

I am currently uncertain how I should proceed to debug this and where in the build chain I need to look for the problem? Is there an issue with the MinGW version, do I need to set additional compile flags for MinGW or what else could it be?

My build currently looks like this:

QT       += core sql widgets network websockets
QT       -= gui
TARGET = FooBar
CONFIG   += console silent c++11
CONFIG   -= app_bundle
TEMPLATE = app
SOURCES += ...
HEADERS += ...

Aucun commentaire:

Enregistrer un commentaire