Project ERROR: Cannot run compiler 'g++'. Maybe you forgot to setup the environment whithin gitlab env

12,635

Solution 1

I had the same error sudo apt install build-essential worked for me.

Solution 2

Well, finally found it!

Turns out that the error message is not clear at all or at least subject to interpretation. It was not an issue with gcc that could not be found. It was however a problem with my env.

Root user did not have /usr/local/lib in its LD_LIBRARY_PATH (when I had it). The reason why is needed is unclear to me but I suspect this is something to do with libisl being necessary for GCC 7.3.0 which is my QMAKE_CC.

Hope this helps somebody

Zaluum

Share:
12,635

Related videos on Youtube

traiangueul
Author by

traiangueul

Updated on June 04, 2022

Comments

  • traiangueul
    traiangueul 4 months

    I've a strange phenomenom happening that I don't know how to investigate. I hope someone already encountered this an can provide tips

    I'm using gitlab CI to build some Qt based projects. gitlab runner calls a script named build.sh that works just fine when I run it manually as "me" in my env dev. However runner raises an error stating "Project ERROR: Cannot run compiler 'g++'. Maybe you forgot to setup the environment". So I made sure g++ was available (g++ -version is OK) and in g++ is in PATH but pbm is still there.

    here is part of the script where the problem resides and the investigation I performed

    echo ">>>>>> now generating makefiles for  ${PROJECT_FILE} <<<<<<"
    export QTDIR=/usr/lib64/qt5
    echo $QTDIR
    echo QMAKESPEC is
    qmake-qt5 -query QMAKE_SPEC
    echo gcc version is
    gcc --version
    g++ --version
    echo $PWD
    whoami
    $cmd_qMake -v
    $cmd_qMake -makefile -o qMakefile ../src/${PROJECT_FILE}
    echo PATH is $PATH
    echo QMAKESPEC is
    qmake-qt5 -query QMAKE_SPEC
    echo gcc version is
    gcc --version
    g++ --version
    

    and here is the output (sorry; this is in debug mode)

    >>>>>> now generating makefiles for  Communication.pro <<<<<<
    + export QTDIR=/usr/lib64/qt5
    + QTDIR=/usr/lib64/qt5
    + echo /usr/lib64/qt5
    /usr/lib64/qt5
    + echo QMAKESPEC is
    QMAKESPEC is
    + qmake-qt5 -query QMAKE_SPEC
    linux-g++
    + echo gcc version is
    gcc version is
    + gcc --version
    gcc (GCC) 7.3.0
    Copyright (C) 2017 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.
    + g++ --version
    g++ (GCC) 7.3.0
    Copyright (C) 2017 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.
    + echo /root/builds/3188cf72/0/EGNOS_V3/AIV-P/AIV-P/Shared/Communication/.buildchain
    /root/builds/3188cf72/0/EGNOS_V3/AIV-P/AIV-P/Shared/Communication/.buildchain
    + whoami
    root
    + qmake-qt5 -v
    QMake version 3.1
    Using Qt version 5.9.2 in /usr/lib64
    + qmake-qt5 -makefile -o qMakefile ../src/Communication.pro
    Project ERROR: Cannot run compiler 'g++'. Maybe you forgot to setup the environment?
    + echo PATH is /opt/gcc-7.3.0/bin:/usr/bin:/usr/sbin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/bin
    PATH is /opt/gcc-7.3.0/bin:/usr/bin:/usr/sbin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/bin
    + echo QMAKESPEC is
    QMAKESPEC is
    + qmake-qt5 -query QMAKE_SPEC
    linux-g++
    + echo gcc version is
    gcc version is
    + gcc --version
    gcc (GCC) 7.3.0
    Copyright (C) 2017 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.
    + g++ --version
    g++ (GCC) 7.3.0
    Copyright (C) 2017 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.
    + for target in '"${TARGETS[@]}"'
    

    As you can see, g++ seems available un runner's root PATH So why is qMake failing?

    Thanks for your help

    Zaluum

    • Neilkantha
      Neilkantha over 2 years
      I have same problem but on windows is there any solution ?

Related