Qt Project fail to build on Travis CI - "error: ISO C++ forbids declaration of ..."



  • I'm working on a Qt desktop application and everything is building under Arch, using CMake 3.10.2, Make 4.2.1, Qt 5.10.1.

    When i try to build on travis i'm getting some dependency errors. Any suggestion ?

    Here's the travis config:

    {
      "language": "cpp",
      "addons": {
        "apt": {
          "sources": [
            "ubuntu-sdk-team"
          ],
          "packages": [
            "qtbase5-dev",
            "qt5-default",
            "qt5-qmake",
            "qttools5-dev-tools",
            "qtbase5-dev-tools",
            "qtdeclarative5-dev",
            "libsqlite3-dev"
          ]
        }
      },
      "before_script": [
        "if [ $TRAVIS_OS_NAME = osx ]; then brew update; brew install qt5; brew link qt5 --force; fi"
      ],
      "script": [
        "cmake .",
        "make -j8"
      ],
      "os": "linux",
      "group": "stable",
      "dist": "trusty",
      "compiler": "gcc",
      "sudo": "required"
    }
    

    Travis error log:

    The command "cmake ." exited with 0.
    8.40s$ make -j8
    [  1%] Generating include/dedicatedslave/data/moc_data.cpp
    [  3%] Generating include/dedicatedslave/logic/moc_processmanager.cpp
    [  5%] Generating include/dedicatedslave/data/moc_dbmanager.cpp
    [  7%] Generating include/dedicatedslave/data/moc_models.cpp
    [  9%] Generating include/dedicatedslave/moc_dedicatedslavelib.cpp
    [ 11%] Generating include/dedicatedslave/moc_dedicatedslavelib_global.cpp
    [ 12%] Generating include/dedicatedslave/logic/moc_app.cpp
    [ 14%] Generating include/dedicatedslave/logic/moc_appsteamapi.cpp
    /home/travis/build/EnthDev/dedicatedslave/include/dedicatedslave/dedicatedslavelib.h:0: Note: No relevant classes found. No output generated.
    /home/travis/build/EnthDev/dedicatedslave/include/dedicatedslave/dedicatedslavelib_global.h:0: Note: No relevant classes found. No output generated.
    [ 16%] Generating include/dedicatedslave/logic/moc_config.cpp
    [ 18%] Generating include/dedicatedslave/logic/moc_helperio.cpp
    [ 20%] Generating include/dedicatedslave/logic/moc_helpersys.cpp
    /home/travis/build/EnthDev/dedicatedslave/include/dedicatedslave/data/dbmanager.h:0: Note: No relevant classes found. No output generated.
    /home/travis/build/EnthDev/dedicatedslave/include/dedicatedslave/data/models.h:0: Note: No relevant classes found. No output generated.
    Scanning dependencies of target dedicatedslave-lib
    [ 22%] Building CXX object CMakeFiles/dedicatedslave-lib.dir/src/dedicatedslavelib.cpp.o
    [ 24%] Building CXX object CMakeFiles/dedicatedslave-lib.dir/src/logic/app.cpp.o
    [ 25%] Building CXX object CMakeFiles/dedicatedslave-lib.dir/src/logic/appsteamapi.cpp.o
    [ 27%] Building CXX object CMakeFiles/dedicatedslave-lib.dir/src/logic/helperio.cpp.o
    [ 29%] Building CXX object CMakeFiles/dedicatedslave-lib.dir/src/logic/helpersys.cpp.o
    [ 31%] Building CXX object CMakeFiles/dedicatedslave-lib.dir/src/logic/config.cpp.o
    [ 33%] Building CXX object CMakeFiles/dedicatedslave-lib.dir/src/logic/processmanager.cpp.o
    [ 35%] Building CXX object CMakeFiles/dedicatedslave-lib.dir/src/data/data.cpp.o
    [ 37%] Building CXX object CMakeFiles/dedicatedslave-lib.dir/src/data/dbmanager.cpp.o
    In file included from /home/travis/build/EnthDev/dedicatedslave/src/data/data.cpp:1:0:
    /home/travis/build/EnthDev/dedicatedslave/include/dedicatedslave/data/data.h:24:27: error: ISO C++ forbids declaration of ‘Q_ENUM’ with no type [-fpermissive]
         Q_ENUM (InstancesTypes);
                               ^
    /home/travis/build/EnthDev/dedicatedslave/src/logic/helpersys.cpp: In static member function ‘static void DedicatedSlave::HelperSys::getInfo()’:
    /home/travis/build/EnthDev/dedicatedslave/src/logic/helpersys.cpp:8:54: error: ‘currentCpuArchitecture’ is not a member of ‘QSysInfo’
             qDebug() << "\tcurrentCpuArchitecture():" << QSysInfo::currentCpuArchitecture();
                                                          ^
    /home/travis/build/EnthDev/dedicatedslave/src/logic/helpersys.cpp:9:43: error: ‘productType’ is not a member of ‘QSysInfo’
             qDebug() << "\tproductType():" << QSysInfo::productType();
                                               ^
    /home/travis/build/EnthDev/dedicatedslave/src/logic/helpersys.cpp:10:46: error: ‘productVersion’ is not a member of ‘QSysInfo’
             qDebug() << "\tproductVersion():" << QSysInfo::productVersion();
                                                  ^
    /home/travis/build/EnthDev/dedicatedslave/src/logic/helpersys.cpp:11:49: error: ‘prettyProductName’ is not a member of ‘QSysInfo’
             qDebug() << "\tprettyProductName():" << QSysInfo::prettyProductName();
                                                     ^
    [ 38%] Building CXX object CMakeFiles/dedicatedslave-lib.dir/src/data/models.cpp.o
    make[2]: *** [CMakeFiles/dedicatedslave-lib.dir/src/logic/helpersys.cpp.o] Error 1
    make[2]: *** Waiting for unfinished jobs....
    /home/travis/build/EnthDev/dedicatedslave/src/data/data.cpp: In constructor ‘DedicatedSlaveData::DedicatedSlaveData(QObject*)’:
    /home/travis/build/EnthDev/dedicatedslave/src/data/data.cpp:41:15: error: ‘qInfo’ was not declared in this scope
             qInfo() << "\tDeserializating and loading data...";
                   ^
    In file included from /home/travis/build/EnthDev/dedicatedslave/include/dedicatedslave/logic/app.h:17:0,
                     from /home/travis/build/EnthDev/dedicatedslave/src/logic/appsteamapi.cpp:1:
    /home/travis/build/EnthDev/dedicatedslave/include/dedicatedslave/data/data.h:24:27: error: ISO C++ forbids declaration of ‘Q_ENUM’ with no type [-fpermissive]
         Q_ENUM (InstancesTypes);
                               ^
    In file included from /home/travis/build/EnthDev/dedicatedslave/include/dedicatedslave/logic/app.h:17:0,
                     from /home/travis/build/EnthDev/dedicatedslave/src/logic/app.cpp:1:
    /home/travis/build/EnthDev/dedicatedslave/include/dedicatedslave/data/data.h:24:27: error: ISO C++ forbids declaration of ‘Q_ENUM’ with no type [-fpermissive]
         Q_ENUM (InstancesTypes);
                               ^
    /home/travis/build/EnthDev/dedicatedslave/src/logic/app.cpp: In constructor ‘DedicatedSlaveApp::DedicatedSlaveApp(const QString&, QObject*)’:
    /home/travis/build/EnthDev/dedicatedslave/src/logic/app.cpp:29:15: error: ‘qInfo’ was not declared in this scope
             qInfo() << "\tcurrentPath:" << QDir::currentPath();
                   ^
    /home/travis/build/EnthDev/dedicatedslave/src/logic/app.cpp: In member function ‘void DedicatedSlaveApp::verifyInstProgress(QString)’:
    /home/travis/build/EnthDev/dedicatedslave/src/logic/app.cpp:152:8: error: ‘qInfo’ was not declared in this scope
      qInfo() << "cmd: " << c;
            ^
    /home/travis/build/EnthDev/dedicatedslave/src/logic/app.cpp:160:13: error: ‘QOverload’ was not declared in this scope
      connect(p, QOverload<int,
                 ^
    /home/travis/build/EnthDev/dedicatedslave/src/logic/app.cpp:160:23: error: expected primary-expression before ‘int’
      connect(p, QOverload<int,
                           ^
    /home/travis/build/EnthDev/dedicatedslave/src/logic/app.cpp:161:22: error: expected primary-expression before ‘>’ token
      QProcess::ExitStatus>::of(&QProcess::finished),
                          ^
    /home/travis/build/EnthDev/dedicatedslave/src/logic/app.cpp:161:23: error: ‘::of’ has not been declared
      QProcess::ExitStatus>::of(&QProcess::finished),
                           ^
    /home/travis/build/EnthDev/dedicatedslave/src/logic/app.cpp: In member function ‘void DedicatedSlaveApp::slot_handleVerfiyFinished(int, QProcess::ExitStatus)’:
    /home/travis/build/EnthDev/dedicatedslave/src/logic/app.cpp:199:8: error: ‘qInfo’ was not declared in this scope
      qInfo() << "Exit code:" << exitCode;
            ^
    make[2]: *** [CMakeFiles/dedicatedslave-lib.dir/src/data/data.cpp.o] Error 1
    /home/travis/build/EnthDev/dedicatedslave/src/data/dbmanager.cpp: In constructor ‘DbManager::DbManager(const QString&)’:
    /home/travis/build/EnthDev/dedicatedslave/src/data/dbmanager.cpp:14:13: error: ‘qInfo’ was not declared in this scope
           qInfo().nospace() << "(DB)\tConnection ok (" << path << ")";
                 ^
    /home/travis/build/EnthDev/dedicatedslave/src/data/dbmanager.cpp: In member function ‘void DbManager::printAllInst() const’:
    /home/travis/build/EnthDev/dedicatedslave/src/data/dbmanager.cpp:151:11: error: ‘qInfo’ was not declared in this scope
         qInfo() << "\tInstances in db:";
               ^
    make[2]: *** [CMakeFiles/dedicatedslave-lib.dir/src/logic/appsteamapi.cpp.o] Error 1
    make[2]: *** [CMakeFiles/dedicatedslave-lib.dir/src/logic/app.cpp.o] Error 1
    make[2]: *** [CMakeFiles/dedicatedslave-lib.dir/src/data/dbmanager.cpp.o] Error 1
    make[1]: *** [CMakeFiles/dedicatedslave-lib.dir/all] Error 2
    make: *** [all] Error 2
    The command "make -j8" exited with 2.
    

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    What OS are you running on Travis ?
    What compiler ? Which version of the compiler ?



  • Hello, thanks @SGaist, ubuntu 14.04.5 LTS with gcc 4.8.4, cmake 3.9.2

    Build system information
    Build language: cpp
    Build group: stable
    Build dist: trusty
    Build id: 343015953
    Job id: 343015955
    Runtime kernel version: 4.4.0-101-generic
    travis-build version: 86020898a
    Build image provisioning date and time
    Tue Dec  5 19:58:13 UTC 2017
    Operating System Details
    Distributor ID:	Ubuntu
    Description:	Ubuntu 14.04.5 LTS
    Release:	14.04
    Codename:	trusty
    Cookbooks Version
    7c2c6a6 https://github.com/travis-ci/travis-cookbooks/tree/7c2c6a6
    git version
    git version 2.15.1
    bash version
    GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)
    gcc version
    gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4
    Copyright (C) 2013 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    docker version
    Client:
     Version:      17.09.0-ce
     API version:  1.32
     Go version:   go1.8.3
     Git commit:   afdb6d4
     Built:        Tue Sep 26 22:42:38 2017
     OS/Arch:      linux/amd64
    Server:
     Version:      17.09.0-ce
     API version:  1.32 (minimum version 1.12)
     Go version:   go1.8.3
     Git commit:   afdb6d4
     Built:        Tue Sep 26 22:41:20 2017
     OS/Arch:      linux/amd64
     Experimental: false
    clang version
    clang version 5.0.0 (tags/RELEASE_500/final)
    Target: x86_64-unknown-linux-gnu
    Thread model: posix
    InstalledDir: /usr/local/clang-5.0.0/bin
    jq version
    jq-1.5
    bats version
    Bats 0.4.0
    shellcheck version
    0.4.6
    shfmt version
    v2.0.0
    ccache version
    ccache version 3.1.9
    Copyright (C) 2002-2007 Andrew Tridgell
    Copyright (C) 2009-2011 Joel Rosdahl
    This program is free software; you can redistribute it and/or modify it under
    the terms of the GNU General Public License as published by the Free Software
    Foundation; either version 3 of the License, or (at your option) any later
    version.
    cmake version
    cmake version 3.9.2
    

  • Moderators

    @alex1a Your gcc on the travis machine is way too old. That's probably your issue. That compiler is 4 years old.

    Arch is cutting edge so your have gcc 7.x.x of some sort depending on when you last ran pacman -Syu. ;) Probably 7.3.0.

    That's 3 whole major revisions compared to your Travis box.

    Edit: I read the error more closely. Can I see data.h? It almost looks like you haven't included QObject since it doesn't know what Q_ENUM is. Or it could be it doesn't know what InstancesTypes are. Either way it may be less of a compiler issue and more of something your later compiler implicitly included that needs to be explicitly included in your older version.



  • @ambershark thanks for your answer, yeah travis build systems are way to old, should i try to install some newer gcc version with travis config ? you are right my gcc version on arch it is 7.3.0.

    ofcourse, here is data.cpp and data.h


  • Moderators

    @alex1a Yea after looking at data.h I bet it's a compiler issue. You can definitely try to upgrade it and see if it helps. Your data.h code seems fine at first glance. Confirmed by the fact it builds properly on your 7.3 gcc with the same Qt version.


  • Moderators

    @alex1a It also looks like you are possibly using different Qt versions though because some of the other errors are things that have changed between Qt versions.

    I.e.

    /home/travis/build/EnthDev/dedicatedslave/src/logic/helpersys.cpp: In static member function ‘static void DedicatedSlave::HelperSys::getInfo()’:
    /home/travis/build/EnthDev/dedicatedslave/src/logic/helpersys.cpp:8:54: error: ‘currentCpuArchitecture’ is not a member of ‘QSysInfo’
             qDebug() << "\tcurrentCpuArchitecture():" << QSysInfo::currentCpuArchitecture();
    

    Although this could be because you didn't #include <QDebug>. That may be one of the explicit includes I was talking about above.



  • @ambershark oki, i appreciate your attention



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