Search code examples
cmakeqt-creatorembedded-linux

Difference in ABI detection between QT Creator and Command Line CMAKE build for Congatec


So, strange one here and I'm hoping someone can point me in the right direction.

Setup: Linux Ubuntu 18.04 CMAKE 3.27 QT Creator 4.8.2

I am using CMAKE to build a Congatec based project. When I run it from the Terminal it builds, but running it from Qt and it fails.

Running from the Linux command prompt and everything builds fine, the build script basically sources the Congatec environment, then runs CMAKE.

This is the relevant output from the ABI detection:

-- The C compiler identification is GNU 10.1.0
-- The CXX compiler identification is GNU 10.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /opt/congatec/sysroots/x86_64-pokysdk-linux/usr/bin/x86_64-poky-linux/x86_64-poky-linux-gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /opt/congatec/sysroots/x86_64-pokysdk-linux/usr/bin/x86_64-poky-linux/x86_64-poky-linux-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done

Now, I want to build the same project in QT Creator, so I have opened up a terminal, sourced the Congatec environment, then started QT Creator (v 4.8.2) which populates the Environment variables as expected and I have had to set some of the Project Settings to point to the Congatec compiler, etc.

When I build from QT, this is the relevant output:

-- The C compiler identification is GNU 10.1.0
-- The CXX compiler identification is GNU 10.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /opt/congatec/sysroots/x86_64-pokysdk-linux/usr/bin/x86_64-poky-linux/x86_64-poky-linux-gcc
-- Check for working C compiler: /opt/congatec/sysroots/x86_64-pokysdk-linux/usr/bin/x86_64-poky-linux/x86_64-poky-linux-gcc - broken
CMake Error at /tritech/cmake-3.27.0-linux-x86_64/share/cmake-3.27/Modules/CMakeTestCCompiler.cmake:67 (message):
  The C compiler

    "/opt/congatec/sysroots/x86_64-pokysdk-linux/usr/bin/x86_64-poky-linux/x86_64-poky-linux-gcc"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: '/tritech/build-Linux_Mayan-Clone_of_Desktop_Qt_5_12_2_GCC_64bit-Default/CMakeFiles/CMakeScratch/TryCompile-phnXLD'

I'm looking for any advice as to why the QT build reports the compiler as being broken?

I cannot see any difference in the Environment or Project variables between the two, so I am a little confused at the moment.

Are there any specific variables I need to check? I've checked all of the CFLAGS, etc and they are the same.

Thanks for any pointers/advice.


Solution

  • This is just to help anyone that may have a similar issue.

    I eventually found the problem and it was quite simple, when you source the Environment and then load QT Creator the Project Variables are pre-populated. Some of these values were "incorrect" and needed to be change manually. Once changed, QT Creator had to be restarted, at this point everything started to build ok.

    The variables I needed to change were:

    CMAKE_C_COMPILER and CMAKE_CXX_COMPILER

    For some reason on my system these were empty within QT Creator but populated when ran in a Terminal.