Can't compile Qt5.10.1 when Qt5.4 works fine



  • I'm trying to upgrade our project from Qt5.4.2 to Qt5.10.1

    My 5.4 kit is:
    Qt Version: Qt 5.4.2 (5.4.2-Win64)
    Compiler: Microsoft Visual C++ Compiler 12 (amd64)
    Debugger: Auto-detected CDB at C:...\8.1\Debuggers\x64\cdb.exe

    My 5.10 kit is:
    Qt Version: Qt 5.10.1 MSVC2017 64bit
    Compiler: Microsoft Visual C++ Compiler 15.0 (amd64)
    Debugger: Auto-detected CDB at C:...\8.1\Debuggers\x64\cdb.exe

    I have no errors at all with the original kit for Qt 5.4. However with the Qt 5.10 kit, I get nearly 300 warnings that "declaration is hiding class member". Now those are just warnings, but what the heck? Why? To top it off, at the very end of the list of warnings i get one critical error preventing compiling: an unresolved external symbol.

    Do I have my kit configured incorrectly? I don't have any kit warnings in the kit management menu. I'm really stumped on this one.



  • Please post the exact errors/warnings. Also, you are changing the compiler in addition to Qt, so the new warnings may be due to that and not specifically Qt.



  • @mchinand said in Can't compile Qt5.10.1 when Qt5.4 works fine:

    Please post the exact errors/warnings. Also, you are changing the compiler in addition to Qt, so the new warnings may be due to that and not specifically Qt.

    Is there a way to save all the errors to a text file? There are literally 295 errors...



  • Post at least the first warning and first error. From your original description, it sounds like your warnings are all similar. Also, include the code snippet that is triggering the error/warning.
    You should be able to copy and paste the errors if you are using QtCreator or Visual Studio as your IDE.



  • As @mchinand suggested, errors/warnings are generated by the compiler and not Qt.

    You can confirm this yourself if you try to compile that project wit Qt 5.10.1 without changing compiler/kit. Unless you are using some Qt functionality that was removed between 5.4.2 and 5.10.1 it should compile the same way with same compiler/kit.


  • Qt Champions 2018

    @casdevel said in Can't compile Qt5.10.1 when Qt5.4 works fine:

    You can confirm this yourself if you try to compile that project wit Qt 5.10.1 without changing compiler/kit. Unless you are using some Qt functionality that was removed between 5.4.2 and 5.10.1 it should compile the same way with same compiler/kit.

    that would require a compiler that is compatible with both Qt versions. it looks like MSVC2013 is the only compiler supported by both.

    one further difference is, that 5.11 always enables C++11, while 5.4 didn't use it.

    Regards



  • @aha_1980 said in Can't compile Qt5.10.1 when Qt5.4 works fine:

    @casdevel said in Can't compile Qt5.10.1 when Qt5.4 works fine:

    You can confirm this yourself if you try to compile that project wit Qt 5.10.1 without changing compiler/kit. Unless you are using some Qt functionality that was removed between 5.4.2 and 5.10.1 it should compile the same way with same compiler/kit.

    that would require a compiler that is compatible with both Qt versions. it looks like MSVC2013 is the only compiler supported by both.

    one further difference is, that 5.11 always enables C++11, while 5.4 didn't use it.

    Regards

    Well now, that's an interesting test - how do I download MSVC2013? I really just need the compiler and whatever minimum is required to go with it. I've already got Visual Studios 17 installed to get the latest compiler, I don't think I can just install the version 13 can I?


  • Qt Champions 2018

    @graniteDev better than guessing what could be is to post at least one of the errors here.

    if a compiler complains, there is always a reason for (in seldom cases a compiler bug, but most often a problem with the code).

    you probably can install MSVC2013 but I don't know if there is a free version.



  • Ok, errors with corresponding code according to the error:

    warning: C4458: declaration of 'configSettings' hides class member

    ConfigSettings::ConfigSettings()
    {
        //create the ini file by setting a value and calling sync
        QSettings configSettings(configFileLocation(), QSettings::IniFormat);
        configSettings.sync();
    }
    

    warning: C4456: declaration of 'container' hides previous local declaration

     QList<QNetworkAddressEntry>addressEntry = iface.addressEntries();
                    foreach (QNetworkAddressEntry add, addressEntry)
                    {
                        if(add.ip().toString().contains(".")) // check for ipv4 address
                        {
                            QHostAddress updatedIP = add.ip();
    
                            if((updatedIP.protocol() == QAbstractSocket::IPv4Protocol)) // check if IP is valid or not
                            {
                                QString ip = add.ip().toString();
                                if (m_ipAddress != ip)
                                {
                                    m_ipAddress = ip;
                                    stopTimer();
                                    break;
                                }
                            }
                        }
                    }
    

    warning: C4458: declaration of 'app' hides class member

     QCoreApplication *app = application();
    

    The list goes on and on like that, 592 errors. None of these errors show up in the version 12 compiler. These are warnings though, they are not stopping the compiling, but really makes me wonder what the heck is going on.

    We did discover (and I say we because it was a join effort with my colleagues) that our soup code is not compatible with the 2017 compiler, so I might need to try the 2013 one if I can figure out how to get it. I don't have control over that code, but it is planned to be updated. All the hard errors that prevent compiling look like they stem from there. Maybe that will fix all the compile issues, but at least until it is fixed, I can't test this.



  • For the first warning, do you have a class member configSettings? Your code:

    QSettings configSettings(configFileLocation(), QSettings::IniFormat);
    

    is creating a new local variable (local to the constructor function only) and is not modifying/initializing the class member variable configSettings.

    Microsoft's explanation of the warning

    I don't see container in the code snippet you included for your second warning.


  • Moderators

    @graniteDev said in Can't compile Qt5.10.1 when Qt5.4 works fine:

    I have no errors at all with the original kit for Qt 5.4. However with the Qt 5.10 kit, I get nearly 300 warnings that "declaration is hiding class member". Now those are just warnings, but what the heck? Why?

    This has nothing to do with the Qt version. It is related to how you named your variables, and how strict your compiler is.

    When you switched from MSVC 2013 (Compiler 12) to MSVC 2017 (Compiler 15), more warnings got enabled by default. Therefore, more potential problems are now reported when they were ignored before.

    What is this potential problem? Well, you gave the same name to more than 1 variable in the same scope. This is legal code (hence why it's a warning and not an error), but it can cause difficult-to-find bugs in the future. To get rid of these warnings, you should use unique names for your local variables and class members. (For example, change your class member from configSettings to m_configSettings)

    To top it off, at the very end of the list of warnings i get one critical error preventing compiling: an unresolved external symbol.

    This probably means that a required DLL (library) can't be found.

    Does your project use an 3rd-party library? What is the name of the unresolved external symbol?

    Note: If the library was built for MSVC 2013, it is not compatible with MSVC 2017.

    Do I have my kit configured incorrectly? I don't have any kit warnings in the kit management menu. I'm really stumped on this one.

    Your kit is fine.


Log in to reply
 

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