2

I'm failing to build the simple Hello World C++ CMake Project in Eclipse with Yocto plugin. Yocto's version is "thud".

The local.conf have the line:

TOOLCHAIN_HOST_TASK_append += " nativesdk-cmake"

I've build the sdk

bitbake myBoard -c populate_sdk

I've installed the sdk, sourced the enviroment setup, launched eclipse from the same terminal and configured the yocto plugin.

The enviroment script have the following variable:

export SDKTARGETSYSROOT=/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi
export CC="arm-fslc-linux-gnueabi-gcc  -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard --sysroot=$SDKTARGETSYSROOT"
export CXX="arm-fslc-linux-gnueabi-g++  -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard --sysroot=$SDKTARGETSYSROOT"
export CPP="arm-fslc-linux-gnueabi-gcc -E  -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard --sysroot=$SDKTARGETSYSROOT"

When I try to build I have the following output (even sourcing the sdk's enviroment setup and then cmake from command line):

$ cmake ..
-- The C compiler identification is GNU 8.2.0
-- The CXX compiler identification is GNU 8.2.0
-- Check for working C compiler: /yocto/sdk/myBoard/sysroots/x86_64-fslcsdk-linux/usr/bin/arm-fslc-linux-gnueabi/arm-fslc-linux-gnueabi-gcc
-- Check for working C compiler: /yocto/sdk/myBoard/sysroots/x86_64-fslcsdk-linux/usr/bin/arm-fslc-linux-gnueabi/arm-fslc-linux-gnueabi-gcc -- broken
CMake Error at /yocto/sdk/myBoard/sysroots/x86_64-fslcsdk-linux/usr/share/cmake-3.12/Modules/CMakeTestCCompiler.cmake:52 (message):
  The C compiler

    "/yocto/sdk/myBoard/sysroots/x86_64-fslcsdk-linux/usr/bin/arm-fslc-linux-gnueabi/arm-fslc-linux-gnueabi-gcc"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /yocto/eclipse-ws/prova/Debug/CMakeFiles/CMakeTmp

    Run Build Command:"/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi/usr/bin/make" "cmTC_4df0b/fast"
    /yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi/usr/bin/make: 1: /yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi/usr/bin/make: Syntax error: word unexpected (expecting ")")


  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:4 (PROJECT)


-- Configuring incomplete, errors occurred!
See also "/yocto/eclipse-ws/prova/Debug/CMakeFiles/CMakeOutput.log".
See also "/yocto/eclipse-ws/prova/Debug/CMakeFiles/CMakeError.log".

Someone see something wrong or missing that is causing the error?

Thank you in advance for any help

Update
The CMakeOutput.log show:

The system is: Linux - 4.15.0-47-generic - x86_64
Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
Compiler: /yocto/sdk/myBoard/sysroots/x86_64-fslcsdk-linux/usr/bin/arm-fslc-linux-gnueabi/arm-fslc-linux-gnueabi-gcc 
Build flags: ;;;--sysroot=/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi;;-march=armv7-a;-mthumb;-mfpu=neon;-mfloat-abi=hard;
Id flags:  

The output was:
0


Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "a.out"

The C compiler identification is GNU, found in "/yocto/eclipse-ws/prova/Debug/CMakeFiles/3.12.2/CompilerIdC/a.out"

Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
Compiler: /yocto/sdk/myBoard/sysroots/x86_64-fslcsdk-linux/usr/bin/arm-fslc-linux-gnueabi/arm-fslc-linux-gnueabi-g++ 
Build flags: ;;;--sysroot=/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi;;-march=armv7-a;-mthumb;-mfpu=neon;-mfloat-abi=hard;;-fpermissive
Id flags:  

The output was:
0

Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "a.out"

The CXX compiler identification is GNU, found in "/yocto/eclipse-ws/prova/Debug/CMakeFiles/3.12.2/CompilerIdCXX/a.out"

Update 2
If I remove everything from the Debug folder and run cmake from command line I have a success and I can build even in Eclipse. If I change something in CMakeLists.txt then the error show up again.

I see that Debug/CMakeFiles/3.12.2/CMakeSystem.cmake is different when it is generated by eclipse or by command line:

Eclipse)

set(CMAKE_HOST_SYSTEM "Linux-4.15.0-47-generic")
set(CMAKE_HOST_SYSTEM_NAME "Linux")
set(CMAKE_HOST_SYSTEM_VERSION "4.15.0-47-generic")
set(CMAKE_HOST_SYSTEM_PROCESSOR "x86_64")

include("/yocto/eclipse-ws/prova/toolchain.cmake")

set(CMAKE_SYSTEM "Linux-4.15.0-47-generic")
set(CMAKE_SYSTEM_NAME "Linux")
set(CMAKE_SYSTEM_VERSION "4.15.0-47-generic")
set(CMAKE_SYSTEM_PROCESSOR "x86_64")

set(CMAKE_CROSSCOMPILING "FALSE")

set(CMAKE_SYSTEM_LOADED 1)

Command Line)

set(CMAKE_HOST_SYSTEM "Linux-4.15.0-47-generic")
set(CMAKE_HOST_SYSTEM_NAME "Linux")
set(CMAKE_HOST_SYSTEM_VERSION "4.15.0-47-generic")
set(CMAKE_HOST_SYSTEM_PROCESSOR "x86_64")

include("/yocto/sdk/aw70pc_am8000/sysroots/x86_64-fslcsdk-linux/usr/share/cmake/OEToolchainConfig.cmake")

set(CMAKE_SYSTEM "Linux")
set(CMAKE_SYSTEM_NAME "Linux")
set(CMAKE_SYSTEM_VERSION "")
set(CMAKE_SYSTEM_PROCESSOR "armv7at2hf-neon-fslc")

set(CMAKE_CROSSCOMPILING "TRUE")

set(CMAKE_SYSTEM_LOADED 1)

From what I understand the eclipse plugin is generating a configuration that use the arm toolchain to compile a test program, not crosscompiling, and obviously it fail. Cmake from command line instead generate it the right way but it's overwritten by the first change in eclipse.

Here's the printenv as requested by danlor

ARCH=arm
CONFIG_SITE=/yocto/sdk/myBoard/site-config-armv7at2hf-neon-fslc-linux-gnueabi
SDKTARGETSYSROOT=/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi
CFLAGS= -O2 -pipe -g -feliminate-unused-debug-types 
KCFLAGS=--sysroot=/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi
OECORE_ACLOCAL_OPTS=-I /yocto/sdk/myBoard/sysroots/x86_64-fslcsdk-linux/usr/share/aclocal
CC=arm-fslc-linux-gnueabi-gcc  -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard --sysroot=/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi
OECORE_DISTRO_VERSION=2.6
OECORE_SDK_VERSION=2.6.1
PKG_CONFIG_SYSROOT_DIR=/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi
CXXFLAGS= -O2 -pipe -g -feliminate-unused-debug-types 
STRIP=arm-fslc-linux-gnueabi-strip
OBJCOPY=arm-fslc-linux-gnueabi-objcopy
CONFIGURE_FLAGS=--target=arm-fslc-linux-gnueabi --host=arm-fslc-linux-gnueabi --build=x86_64-linux --with-libtool-sysroot=/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi
OECORE_NATIVE_SYSROOT=/yocto/sdk/myBoard/sysroots/x86_64-fslcsdk-linux
RANLIB=arm-fslc-linux-gnueabi-ranlib
OBJDUMP=arm-fslc-linux-gnueabi-objdump
AS=arm-fslc-linux-gnueabi-as 
AR=arm-fslc-linux-gnueabi-ar
TARGET_PREFIX=arm-fslc-linux-gnueabi-
NM=arm-fslc-linux-gnueabi-nm
CXX=arm-fslc-linux-gnueabi-g++  -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard --sysroot=/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi
OECORE_TARGET_OS=linux-gnueabi
OECORE_TARGET_ARCH=arm
OECORE_TARGET_SYSROOT=/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi
CROSS_COMPILE=arm-fslc-linux-gnueabi-
OE_CMAKE_TOOLCHAIN_FILE=/yocto/sdk/myBoard/sysroots/x86_64-fslcsdk-linux/usr/share/cmake/OEToolchainConfig.cmake
CPPFLAGS=
LDFLAGS=-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed
OE_CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX=
OECORE_BASELIB=lib
PKG_CONFIG_PATH=/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi/usr/lib/pkgconfig:/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi/usr/share/pkgconfig
CPP=arm-fslc-linux-gnueabi-gcc -E  -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard --sysroot=/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi
LD=arm-fslc-linux-gnueabi-ld  --sysroot=/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi

toolchain.cmake

# CMake system name must be something like "Linux".
# This is important for cross-compiling.
set(CMAKE_SYSTEM_PROCESSOR )
set(CMAKE_C_COMPILER arm-fslc-linux-gnueabi-gcc)
set(CMAKE_CXX_COMPILER arm-fslc-linux-gnueabi-g++)
set(CMAKE_C_FLAGS "   --sysroot=/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi  -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard " CACHE STRING "CFLAGS")
set(CMAKE_CXX_FLAGS "   --sysroot=/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi  -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard  -fpermissive" CACHE STRING "CXXFLAGS")
set(CMAKE_C_FLAGS_RELEASE "  --sysroot=/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi  -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard  -DNDEBUG" CACHE STRING "CFLAGS for release")
set(CMAKE_CXX_FLAGS_RELEASE "  --sysroot=/yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi  -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard  -DNDEBUG" CACHE STRING "CXXFLAGS for release")
set(CMAKE_C_LINK_FLAGS "" CACHE STRING "LDFLAGS")
set(CMAKE_CXX_LINK_FLAGS "" CACHE STRING "LDFLAGS")

# only search in the paths provided so cmake doesnt pick
# up libraries and tools from the native build machine
set(CMAKE_FIND_ROOT_PATH /yocto/sdk/myBoard/sysroots/x86_64-fslcsdk-linux /yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi )
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

# Use qt.conf settings
set(ENV{QT_CONF_PATH} qt.conf)

# We need to set the rpath to the correct directory as cmake does not provide any
# directory as rpath by default
set(CMAKE_INSTALL_RPATH )

# Use native cmake modules
set(CMAKE_MODULE_PATH /cmake/Modules/)

# add for non /usr/lib libdir, e.g. /usr/lib64
set(CMAKE_LIBRARY_PATH ${libdir} ${base_libdir})

Workaround

I've found a way out

Adding the following 2 lines in CMakeLists.txt will tell cmake that the compiler works and to not test it
SET (CMAKE_C_COMPILER_WORKS 1)
SET (CMAKE_CXX_COMPILER_WORKS 1)

Now I can build successfully my own program and it works like a charm.
It means that Eclipse can crosscompile my program but when checking the system it build the test program in a different way.

Ramon La Pietra
  • 609
  • 7
  • 13
  • Take a look at the output and error logs do they show any additional details. If you use the `--debug-trycompile` option the CMakeTmp project will not be deleted and you can inspect the project. – fdk1342 Apr 12 '19 at 14:50
  • @Fred: I've updated with the CMakeOutput.log. Unfortunately I don't have any additional details. – Ramon La Pietra Apr 12 '19 at 15:39
  • which yocto version are you using? cmake used to be broken in the sdk in rocko, I believe. – Oleksandr Kravchuk Apr 12 '19 at 19:22
  • @Oleksandr Kravchuk: I'm using the latest thud release. The BSP layer is meta-freescale – Ramon La Pietra Apr 15 '19 at 09:05
  • I've seen it mentioned that nativesdk-cmake had issues at some point. Update 2 shows the problem with eclipse not using the correct settings. I read that you need to source the SDK script in a terminal and then launch eclipse from the command line. That has always worked for me when using Yocto / CMake / vscode IDE. – fdk1342 Apr 17 '19 at 19:36
  • It appears that the eclipse is using the wrong toolchain file. Refer to https://stackoverflow.com/a/41973913/1028434. – fdk1342 Apr 17 '19 at 19:42
  • In the local.conf I already have the TOOLCHAIN_HOST_TASK_append += " nativesdk-cmake" and I have already sourced the sdk enviroment script – Ramon La Pietra Apr 19 '19 at 15:43

1 Answers1

0

It seems that you're trying to use the cross-compiled make tool (the one that is compiled for your TARGET, i.e. /yocto/sdk/myBoard/sysroots/armv7at2hf-neon-fslc-linux-gnueabi/usr/bin/make) instead of the HOST make tool (/yocto/sdk/myBoard/sysroots/x86_64-fslcsdk-linux/usr/bin/make). Change it and try again :)

danrodlor
  • 1,329
  • 8
  • 16