Subject: Cmake CROSS COMPILE problem [PLEASE HELP, URGENT] #yocto #toolchain #sdk To: yocto@lists.yoctoproject.org From: "Bel Hadj Salem Talel" X-Originating-Location: TN (197.27.106.84) X-Originating-Platform: Linux Firefox 82 User-Agent: GROUPS.IO Web Poster MIME-Version: 1.0 Date: Wed, 04 Nov 2020 09:03:35 -0800 Message-ID: <35SW.1604509415488140085.romI@lists.yoctoproject.org> Content-Type: multipart/alternative; boundary="kKJIOMaTRFgqTimCrYDt" --kKJIOMaTRFgqTimCrYDt Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hi All, I'm in serious task here and I need to cross compile a Cmake project. I need to send an SDK to a client with steps to cross compile the project. This project is compiling successfully via a Yocto recipe that inherits cm= ake. I extracted an SDK from the main image adding TOOLCHAIN_HOST_TASK_append= =3D" nativesdk-cmake" to add the Toolchain cmake file which is located und= er: /home/talel/Documents/sensesdk/sysroots/x86_64-pokysdk-linux/usr/share/= cmake/OEToolchainConfig.cmake : Here is its content: *set( CMAKE_SYSTEM_NAME Linux )* *set( CMAKE_C_FLAGS $ENV{CFLAGS} CACHE STRING "" FORCE )* *set( CMAKE_CXX_FLAGS $ENV{CXXFLAGS}=C2=A0 CACHE STRING "" FORCE )* *set( CMAKE_ASM_FLAGS ${CMAKE_C_FLAGS} CACHE STRING "" FORCE )* *set( CMAKE_LDFLAGS_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE )* *set( CMAKE_SYSROOT $ENV{OECORE_TARGET_SYSROOT} )* *set( CMAKE_FIND_ROOT_PATH $ENV{OECORE_TARGET_SYSROOT} )* *set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )* *set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )* *set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )* *set( CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY )* *set(CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX "$ENV{OE_CMAKE_FIND_LIBRARY_CUST= OM_LIB_SUFFIX}")* *# Set CMAKE_SYSTEM_PROCESSOR from the sysroot name (assuming processor-di= stro-os).* *if ($ENV{SDKTARGETSYSROOT} MATCHES "/sysroots/([a-zA-Z0-9_-]+)-.+-.+")* *set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_MATCH_1})* *endif()* *# Include the toolchain configuration subscripts* *file( GLOB toolchain_config_files "${CMAKE_TOOLCHAIN_FILE}.d/*.cmake" )* *foreach(config ${toolchain_config_files})* *include(${config})* *endforeach()* The project is working with gRPC and Protobuf. There is a .cmake files tha= t are responsible for searching for gRPC and Protobuf libs Here is what I tried after sourcing the SDK environment: 1) A simple "cmake .." with no options: *Setting build type to 'RelWithDebInfo' as none was specified.* *-- Toolchain file defaulted to '/home/talel/Documents/sensesdk/sysroots/x= 86_64-pokysdk-linux/usr/share/cmake/OEToolchainConfig.cmake'* *-- The C compiler identification is GNU 7.3.0* *-- The CXX compiler identification is GNU 7.3.0* *-- Check for working C compiler: /home/talel/Documents/sensesdk/sysroots/= x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-gcc* *-- Check for working C compiler: /home/talel/Documents/sensesdk/sysroots/= x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-gcc -- w= orks* *-- Detecting C compiler ABI info* *-- Detecting C compiler ABI info - done* *-- Detecting C compile features* *-- Detecting C compile features - done* *-- Check for working CXX compiler: /home/talel/Documents/sensesdk/sysroot= s/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-g++* *-- Check for working CXX compiler: /home/talel/Documents/sensesdk/sysroot= s/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-g++ --= works* *-- Detecting CXX compiler ABI info* *-- Detecting CXX compiler ABI info - done* *-- Detecting CXX compile features* *-- Detecting CXX compile features - done* *CMake Warning at /home/talel/Documents/sensesdk/sysroots/x86_64-pokysdk-l= inux/usr/share/cmake-3.16/Modules/FindProtobuf.cmake:499 (message):* *Protobuf compiler version 3.12.3 doesn't match library version 3.11.4* *Call Stack (most recent call first):* *CMakeLists.txt:23 (find_package)* *-- Found Protobuf: /home/talel/Documents/sensesdk/sysroots/aarch64-poky-l= inux/usr/lib/libprotobuf.so;-lpthread (found version "3.11.4")* *-- Could NOT find gRPC (missing: GRPC_CPP_PLUGIN)* *-- Configuring done* *-- Generating done* *-- Build files have been written to: /home/talel/Desktop/sense_software_2= /build* protobuf is found, but not gRPC, now when I make: *make[2]: *** No rule to make target 'GRPC_CPP_PLUGIN-NOTFOUND', needed by= 'protos/sense_api_settings.grpc.pb.cc'.=C2=A0 Stop.* *CMakeFiles/Makefile2:734: recipe for target 'protos/CMakeFiles/sense_api_= settings_grpc.dir/all' failed* *make[1]: *** [protos/CMakeFiles/sense_api_settings_grpc.dir/all] Error 2* *Makefile:129: recipe for target 'all' failed* *make: *** [all] Error 2 * I searched for a solution and I added the *-DCMAKE_PREFIX_PATH=3D/home/t= alel/Documents/sensesdk/sysroots/aarch64-poky-linux/usr* option to my SDK r= ootfs Here is the result of cmake..: *-- Check for working C compiler: /home/talel/Documents/sensesdk/sysroots/= x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-gcc -- b= roken* *CMake Error at /home/talel/Documents/sensesdk/sysroots/x86_64-pokysdk-lin= ux/usr/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake:60 (message):* *The C compiler* *"/home/talel/Documents/sensesdk/sysroots/x86_64-pokysdk-linux/usr/bin/aar= ch64-poky-linux/aarch64-poky-linux-gcc"* *is not able to compile a simple test program.* *It fails with the following output:* *Change Dir: /home/talel/Desktop/sense_software_2/build/CMakeFiles/CMakeTm= p* *Run Build Command(s):/home/talel/Documents/sensesdk/sysroots/aarch64-poky= -linux/usr/bin/make cmTC_2a27c/fast && /home/talel/Documents/sensesdk/sysro= ots/aarch64-poky-linux/usr/bin/make: 1: /home/talel/Documents/sensesdk/sysr= oots/aarch64-poky-linux/usr/bin/make: Syntax error: word unexpected (expect= ing ")")* I tried to add C and CXX options : *-DCMAKE_C_COMPILER_WORKS=3D1 -DCMAKE_C= XX_COMPILER_WORKS=3D1* : Now it shows this: */home/talel/Documents/sensesdk/sysroots/aarch64-poky-linux/usr/bin/protoc= : 1: /home/talel/Documents/sensesdk/sysroots/aarch64-poky-linux/usr/bin/pro= toc: ELF=02=01=01=02=EF=BF=BD=01=14=12@2@8: not found* */home/talel/Documents/sensesdk/sysroots/aarch64-poky-linux/usr/bin/protoc= : 2: /home/talel/Documents/sensesdk/sysroots/aarch64-poky-linux/usr/bin/pro= toc: Syntax error: ")" unexpected* *CMake Warning at /home/talel/Documents/sensesdk/sysroots/x86_64-pokysdk-l= inux/usr/share/cmake-3.16/Modules/FindProtobuf.cmake:499 (message):* *Protobuf compiler version doesn't match library version 3.11.4* and now when I make same error ; syntax error in protobuf Here is the main CMakeLists: cmake_minimum_required (VERSION 3.5) set (ex_ver "01" ) # Set a default build type if none was specified if ( NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) message ( "Setting build type to 'RelWithDebInfo' as none was specified." = ) set (CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of buil= d." FORCE) # Set the possible values of build type for cmake-gui set_property ( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo" ) endif () project (ex VERSION ${ ex_ver }) # set the C++ standard to C++ 11 set (CMAKE_CXX_STANDARD 11) list (APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) include (CompileProtos) set (protobuf_MODULE_COMPATIBLE TRUE ) find_package (Protobuf REQUIRED) #find_package(gRPC REQUIRED) set (_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf) if (CMAKE_CROSSCOMPILING) find_program (_PROTOBUF_PROTOC protoc) find_program (_gRPC_CPP_PLUGIN grpc_cpp_plugin) else () set (_PROTOBUF_PROTOC $) endif () #message(STATUS "Using protobuf ${protobuf_VERSION}") # Find gRPC installation # Looks for gRPCConfig.cmake file installed by gRPC's cmake installation. find_package (GRPC REQUIRED) set (_GRPC_GRPCPP_REFLECTION gRPC::grpc++_reflection) if (CMAKE_CROSSCOMPILING) find_program (_GRPC_CPP_PLUGIN_EXECUTABLE grpc_cpp_plugin) else () set (_GRPC_CPP_PLUGIN_EXECUTABLE $) endif () # uncomment for PC #find_package(fmt REQUIRED) #add_compile_definitions(SPDLOG_FMT_EXTERNAL) #Add sub-directories add_subdirectory (protos) add_subdirectory (systemd) add_subdirectory (certs) add_subdirectory (services) add_subdirectory (lib) add_subdirectory (tools) add_subdirectory (core) Help me please on this. It is really urgent, I tried a lot. Thanks, Talel --kKJIOMaTRFgqTimCrYDt Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hi All,

I'm in serious task here and I need to cross compile a C= make project.
I need to send an SDK to a client with steps to cross co= mpile the project.
This project is compiling successfully via a Yocto = recipe that inherits cmake.
I extracted an SDK from the main image add= ing TOOLCHAIN_HOST_TASK_append=3D" nativesdk-cmake" to add the Toolchain cm= ake file which is located under: /home/talel/Documents/sensesdk/sysroots/x8= 6_64-pokysdk-linux/usr/share/cmake/OEToolchainConfig.cmake :
Here is i= ts content:

set( CMAKE_SYSTEM_NAME Linux )
set( CMAKE_C_FLAGS $ENV{CFLAGS} CACHE STRING "" FORCE )set( CMAKE_CXX_FLAGS $ENV{CXXFLAGS}  CACHE STRING "" FORCE= )
set( CMAKE_ASM_FLAGS ${CMAKE_C_FLAGS} CACHE STRING= "" FORCE )
set( CMAKE_LDFLAGS_FLAGS ${CMAKE_CXX_FLAG= S} CACHE STRING "" FORCE )
set( CMAKE_SYSROOT $ENV{OE= CORE_TARGET_SYSROOT} )
set( CMAKE_FIND_ROOT_PATH $ENV= {OECORE_TARGET_SYSROOT} )
set( CMAKE_FIND_ROOT_PATH_M= ODE_PROGRAM NEVER )
set( CMAKE_FIND_ROOT_PATH_MODE_LI= BRARY ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE O= NLY )
set( CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY )
set(CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX "$ENV{OE_CMAK= E_FIND_LIBRARY_CUSTOM_LIB_SUFFIX}")
# Set CMAKE_SYSTE= M_PROCESSOR from the sysroot name (assuming processor-distro-os).<= br />if ($ENV{SDKTARGETSYSROOT} MATCHES "/sysroots/([a-zA-Z0-9_-]+)= -.+-.+")
  set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_MA= TCH_1})
endif()
# Include the t= oolchain configuration subscripts
file( GLOB toolchai= n_config_files "${CMAKE_TOOLCHAIN_FILE}.d/*.cmake" )
= foreach(config ${toolchain_config_files})
  = ;  include(${config})
endforeach()


The project is working with gRPC and Protobuf. There is a .cma= ke files that are responsible for searching for gRPC and Protobuf libs

Here is what I tried after sourcing the SDK environment:
1) A s= imple "cmake .." with no options:

Setting build type to = 'RelWithDebInfo' as none was specified.
-- Toolchain = file defaulted to '/home/talel/Documents/sensesdk/sysroots/x86_64-pokysdk-l= inux/usr/share/cmake/OEToolchainConfig.cmake'
-- The = C compiler identification is GNU 7.3.0
-- The CXX com= piler identification is GNU 7.3.0
-- Check for workin= g C compiler: /home/talel/Documents/sensesdk/sysroots/x86_64-pokysdk-linux/= usr/bin/aarch64-poky-linux/aarch64-poky-linux-gcc
-- = Check for working C compiler: /home/talel/Documents/sensesdk/sysroots/x86_6= 4-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-gcc -- works<= /strong>
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done

-- Detectin= g C compile features
-- Detecting C compile features = - done
-- Check for working CXX compiler: /home/talel= /Documents/sensesdk/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linu= x/aarch64-poky-linux-g++
-- Check for working CXX com= piler: /home/talel/Documents/sensesdk/sysroots/x86_64-pokysdk-linux/usr/bin= /aarch64-poky-linux/aarch64-poky-linux-g++ -- works
-= - Detecting CXX compiler ABI info
-- Detecting CXX co= mpiler ABI info - done
-- Detecting CXX compile featu= res
-- Detecting CXX compile features - done=
CMake Warning at /home/talel/Documents/sensesdk/sysroots/x86_= 64-pokysdk-linux/usr/share/cmake-3.16/Modules/FindProtobuf.cmake:499 (messa= ge):
  Protobuf compiler version 3.12.3 doesn't = match library version 3.11.4
Call Stack (most recent = call first):
  CMakeLists.txt:23 (find_package)<= /strong>
-- Found Protobuf: /home/talel/Documents/sensesdk/sys= roots/aarch64-poky-linux/usr/lib/libprotobuf.so;-lpthread (found version "3= .11.4")
-- Could NOT find gRPC (missing: GRPC_CPP_PL= UGIN)
-- Configuring done
-- G= enerating done
-- Build files have been written to: /= home/talel/Desktop/sense_software_2/build

protobuf is f= ound, but not gRPC, now when I make:
make[2]: *** No rule to = make target 'GRPC_CPP_PLUGIN-NOTFOUND', needed by 'protos/sense_api_setting= s.grpc.pb.cc'.  Stop.
CMakeFiles/Makefile2:734: = recipe for target 'protos/CMakeFiles/sense_api_settings_grpc.dir/all' faile= d
make[1]: *** [protos/CMakeFiles/sense_api_settings_= grpc.dir/all] Error 2
Makefile:129: recipe for target= 'all' failed
make: *** [all] Error 2

I searched for a solution and I added the -DCMAKE_PREFIX_PATH= =3D/home/talel/Documents/sensesdk/sysroots/aarch64-poky-linux/usr= option to my SDK rootfs
Here is the result of cmake..:

-- Check for working C compiler: /home/talel/Documents/sensesdk/sysroo= ts/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-gcc -= - broken

CMake Error at /home/talel/Documents/sensesd= k/sysroots/x86_64-pokysdk-linux/usr/share/cmake-3.16/Modules/CMakeTestCComp= iler.cmake:60 (message):
  The C compiler
    "/home/talel/Documents/sensesdk/sysroots= /x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-gcc"
  is not able to compile a simple test program.
  It fails with the following output:
    Change Dir: /home/talel/Desktop/sense_software= _2/build/CMakeFiles/CMakeTmp
    Run B= uild Command(s):/home/talel/Documents/sensesdk/sysroots/aarch64-poky-linux/= usr/bin/make cmTC_2a27c/fast && /home/talel/Documents/sensesdk/sysr= oots/aarch64-poky-linux/usr/bin/make: 1: /home/talel/Documents/sensesdk/sys= roots/aarch64-poky-linux/usr/bin/make: Syntax error: word unexpected (expec= ting ")")

I tried to add C and CXX options : -D= CMAKE_C_COMPILER_WORKS=3D1 -DCMAKE_CXX_COMPILER_WORKS=3D1:
No= w it shows this:

/home/talel/Documents/sensesdk/sysroots= /aarch64-poky-linux/usr/bin/protoc: 1: /home/talel/Documents/sensesdk/sysro= ots/aarch64-poky-linux/usr/bin/protoc: ELF=02=01=01=02=EF=BF=BD=01=14=12@2@= 8: not found
/home/talel/Documents/sensesdk/sysroots/= aarch64-poky-linux/usr/bin/protoc: 2: /home/talel/Documents/sensesdk/sysroo= ts/aarch64-poky-linux/usr/bin/protoc: Syntax error: ")" unexpected=
CMake Warning at /home/talel/Documents/sensesdk/sysroots/x86_= 64-pokysdk-linux/usr/share/cmake-3.16/Modules/FindProtobuf.cmake:499 (messa= ge):
  Protobuf compiler version doesn't match l= ibrary version 3.11.4

and now when I make same error ; = syntax error in protobuf

Here is the main CMakeLists:
cmake_minimum_required (VERSION 3.5)

set(ex_ver "01")

# Set a default b= uild type if none was specified
if(NOT CMAKE_BUILD_TYPE AND = NOT CMAKE_CONFIGURATION_TYPES)
message("Setting build type to 'R= elWithDebInfo' as none was specified." set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gu= i
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo"endif()

project(ex VERSION ${ex_ver})

# set the C++ sta= ndard to C++ 11
set(CMAKE_CXX_STANDARD 11)

list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

include(CompileProtos)
set(protobuf_MODULE_COMPATIBLE TRU= E)
find_package(Protobuf REQUIRED)
#find_package(gRP= C REQUIRED)

set(_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf)
if(CMAKE_CROSSCOMPILING)
find_program(_PROTOBUF_PROTOC protoc)
find_program(_gRPC_CPP_PLUGIN grpc_cpp_plugin)
else()
set(_PROTOBUF_PROTOC $<TARGET_FILE:protobuf::protoc>)
endif()
#message(STATUS "= Using protobuf ${protobuf_VERSION}")

# Find gRPC installation
# Looks for gRPCC= onfig.cmake file installed by gRPC's cmake installation.
find_package(GRPC REQUIRED)

set(_GRPC_GRPCPP_REFLECTION gRPC::grpc++_reflection)
if(CMAKE_CROSSCOMPILING)
find_program(_GRPC_CPP_PLUGIN_EXECUTABLE grpc_cpp_plugin)
else()
set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:gRPC::grpc_cpp_plugin&g= t;)
endif()

# uncomment for P= C
#find_package(fmt= REQUIRED)
#add_compile_defi= nitions(SPDLOG_FMT_EXTERNAL)

#Add sub-director= ies
add_subdirectory(protos)
add_subdirectory(systemd)
add_subdirectory(certs)
add_subdirectory(services)
add_subdirectory(lib)
add_subdirectory(tools)
add_subdirectory(core)



Help me please on this. It is really urgent, I tried a lot.
Tha= nks, Talel --kKJIOMaTRFgqTimCrYDt--