What compilers do you use with Qt?



  • Since I'm moving from Visual studio I'm no longer bound to its compiler, so I'm wondering what else is out there. I don't have any certain criteria, what makes a good compiler? Which ones work best with Qt Creator?



  • On Windows I use the one provided with Visual Studio Community (msvc2012)
    Not sure if there is a "best" compiler, I'm not into that sort of thing maybe someone else can answer? Msvc is certainly the easiest to install.
    Have fun with Qt!


  • Moderators

    If you stick to Qt's reference configurations ("see:":http://doc.qt.io/qt-5/supported-platforms.html "and":http://doc.qt.io/QtSupportedPlatforms/index.html) then there aren't so many options left. So basically it boils down to

    • gcc on Linux
    • MSVC on Windows
    • Clang on Mac OS

    I don't see any reason to use anything else than MSVC on Windows.



  • There is a good reason to use different than MSVC on Windows if you do heavy numerical computations and need the best optimization possible..
    In this case we go with Intel compiler. But it does not really matter when you write GUI.


  • Lifetime Qt Champion

    Hi,

    On windows you also have the MinGW package which comes with the corresponding compiler



  • I have both MSVC 2013 and MinGW on Windows. My app is destined only for windows at this point so no need for linux or Mac but I have run Qt on them for test projects.

    I was a little shocked to see that code I've written under Qt using MSVC 2013 that compiles and links with no warnings but when compiled using MinGW had quite a few warnings and some errors.

    I'm sure there are command line compiler flags to change all that but it doesn't give one a great feeling. To get some things that work perfect under MSVC 2013 to even compile I had to change some references to non reference calls and there was a lot of complaining by MinGW about initialization order.


  • Lifetime Qt Champion

    @ SysTech, you would have had the same with gcc. All these compilers have different base to "complain about" even OS X's gcc and Linux gcc didn't complain about the same things.



  • Understood. I guess its to be expected.


  • Moderators

    [quote author="SysTech" date="1424639572"]I was a little shocked to see that code I've written under Qt using MSVC 2013 that compiles and links with no warnings but when compiled using MinGW had quite a few warnings and some errors.

    I'm sure there are command line compiler flags to change all that but it doesn't give one a great feeling. To get some things that work perfect under MSVC 2013 to even compile I had to change some references to non reference calls and there was a lot of complaining by MinGW about initialization order.[/quote]Spare a thought for the Qt engineers -- they worked hard to eliminate warnings on all reference compilers :)

    Anyway, differences in what compilers are allowed could be because:

    • One compiler is stricter than the other
    • One compiler has a bug
    • The compilers interpret parts of the C++ standard differently
    • You're using a non-standard C++ extension that's supported by one compiler but not the other

    See "here":http://forums.xkcd.com/viewtopic.php?f=11&t=83418 for example.

    Regarding initialization order, see "here":http://stackoverflow.com/questions/12222417/why-should-i-initialize-member-variables-in-the-order-theyre-declared-in for the rationale.



  • JKSH
    Thanks for list and references! Still trying to get totally up to speed.

    One thing that was puzzling was:

    @void TestClass::setSomething( QString &newStr )
    {
    m_myString = newStr;
    }@

    m_myString was declared in the class as:

    @QString m_myString;@

    This compiled, no warnings, and worked just fine in MSVC. However it caused errors in MinGW. Unfortunately I don't have the code / errors handy to list and its not that important. But I was a little puzzled.

    Perhaps it is something about how QString is setup. I didn't spend time on it.



  • I forgot to mention, I'm looking for full support of C++11 standart, std::thread in particular. Although reading briefly through qt docs I noticed Qt has its own thread class, is it any different?

    With all these differences between compilers and platforms that are around, does something like "pure" C++ exists actually? Or is it rather various branches that have common roots nowadays?


  • Moderators

    [quote author="Clint Westwood" date="1424565771"]Since I'm moving from Visual studio I'm no longer bound to its compiler, so I'm wondering what else is out there. I don't have any certain criteria, what makes a good compiler? Which ones work best with Qt Creator?[/quote]For generic compilation, both MSVC 2013 and MinGW 4.9 work perfectly well on Windows, and both support C++11.

    If you want to use Qt Multimedia or Qt WebEngine, MSVC supports those modules better.

    If you want to target old PCs (specifically Windows XP), then MinGW requires less work to set up.

    [quote author="SysTech" date="1424647599"]One thing that was puzzling was:

    @void TestClass::setSomething( QString &newStr )
    {
    m_myString = newStr;
    }@

    m_myString was declared in the class as:

    @QString m_myString;@

    This compiled, no warnings, and worked just fine in MSVC. However it caused errors in MinGW.[/quote]I can't see anything wrong with that code, so I have no idea what cause it (the error message would be useful though). On a side note, the Qt convention is to use a const reference instead of modifiable reference.

    [quote author="Clint Westwood" date="1424647819"]I forgot to mention, I'm looking for full support of C++11 standart, std::thread in particular. Although reading briefly through qt docs I noticed Qt has its own thread class, is it any different?[/quote]Both MSVC 2013 and MinGW 4.9 support std::thread. QThread can easily run an event loop, so you can use signals and slots between threads (that's much harder with std::thread)

    Note that Qt has a few different ways to use threads, not just QThread. See "Multithreading Technologies in Qt":http://doc.qt.io/qt-5/threads-technologies.html

    [quote author="Clint Westwood" date="1424647819"]With all these differences between compilers and platforms that are around, does something like "pure" C++ exists actually? Or is it rather various branches that have common roots nowadays?[/quote]Each compiler has its own extensions to C++, but you can ignore the extensions and stick to standards-compliant C++.

    See:



  • Thanks for answers!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.