6

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

traiangueul
  • 71
  • 1
  • 1
  • 5

3 Answers3

8

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

schoon
  • 2,858
  • 3
  • 46
  • 78
1

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

traiangueul
  • 71
  • 1
  • 1
  • 5
1

In most of the cases, this is a problem with environment settings - especially path to compiler/toolchain etc.

On Windows it concerns PATH environment variable's setting. For example - when you use minGW toolchain with g++ you should have PATH set e.g.

C:\Qt\Tools\mingw810_64\bin

However sometimes setting it in Windows Control Panel is insufficient, because other application (you have installed) could play with PATH and overrided it. So I recommend to everyone facing this issue and fired all found possible solution, first - to check if printing PATH in cmd (command line Windows tool) follows PATH you have set in Control Panel. If not you can try:

  1. Find reason for PATH is different,
  2. Check if it is not problem described here: https://stackoverflow.com/a/65163187/8389251
  3. Add new Windows User (new account) - and run there Qt Creator and compilation. (Still ensure you have properly set PATH in Control Panel)
Antares
  • 518
  • 6
  • 11