0

I am using CMake with QNX Momentics. For that I executed the command

cmake -DCMAKE_TOOLCHAIN_FILE=/my-path/qnx.cmake

on terminal which shown me the below mentioned error:

ERROR:-
"-- The C compiler identification is unknown
CMake Error at CMakeLists.txt:7 (project):
  The CMAKE_C_COMPILER:
    /home/mobis/MTCI/Test/host/linux/x86_64/usr/bin/ntox86_64-gcc
  is not a full path to an existing compiler tool.
  Tell CMake where to find the compiler by setting either the environment
  variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
  the compiler, or to the compiler name if it is in the PATH."
  1. I have checked for ntox86_64-gcc compiler in my local pc and it is present at /hom/Test/host/linux/x86_64/usr/bin location.

  2. I have tried to build by giving compiler path at command line with CMake but it shows same error.

  3. Tried below solution even after that same error:

    CMAKE_C_COMPILER is not a full path to an existing compiler tool

    export CC=/usr/bin/gcc
    export CXX=/usr/bin/g++
    

Please find below my qnx.cmake:

set(CMAKE_SYSTEM_NAME QNX)
set(CMAKE_HOST_SYSTEM_NAME QNX)
set(CMAKE_SYSTEM_VERSION 7.0.0)
set(arch ntox86_64)
set(QNX_PROCESSOR x86_64)
SET( TOOLCHAIN QNX )

#Check environment variables
if ("$ENV{QNX_HOST}" STREQUAL "")
    message(FATAL_ERROR "QNX_HOST environment variable not set")
endif()

if ("$ENV{QNX_TARGET}" STREQUAL "")
    message(FATAL_ERROR "QNX_TARGET environment variable not set")
endif()

set(QNX_HOST "$ENV{QNX_HOST}")
set(QNX_TARGET "$ENV{QNX_TARGET}")
set(CMAKE_C_COMPILER "${QNX_HOST}/usr/bin/${arch}-gcc")
set(CMAKE_CXX_COMPILER "${QNX_HOST}/usr/bin/nto${QCC_NTOARCH}-g++")


set(CMAKE_C_FLAGS_DEBUG "-g")
set(CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG")
set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g")
set(CMAKE_CXX_FLAGS_DEBUG "-g -D_DEBUG")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")

set(CMAKE_FIND_ROOT_PATH "${QNX_TARGET}")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

Please find below my CMakeLists.txt:

cmake_minimum_required(VERSION 3.14.2)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_BUILD_TYPE Release)
project(Test VERSION 1.0     DESCRIPTION "CoreLSP FOlder structure     project"   LANGUAGES C)
set(SRCS 
   main.c
   printing.c
   ) 
add_executable(Test ${SRCS})

Expected:

  • The project should be built successfully and makefile should be produced so that I could import project into QNX Momentics IDE (Linux based Host OS).
Tsyvarev
  • 60,011
  • 17
  • 110
  • 153
sunny
  • 1
  • 2
  • I have referred [link] "https://github.com/mapbox/mapbox-gl-native/blob/master/platform/qt/qnx.cmake" to use qnx.cmake – sunny Jul 24 '19 at 01:17
  • CMake tries the exact compiler you set in your toolchain (`CMAKE_C_COMPILER` variable). If this setting is wrong, then fix your toolchain. You may add `message("C compiler: ${CMAKE_C_COMPILER}")` into your toolchain for verify that you use the correct path. – Tsyvarev Jul 24 '19 at 08:12
  • @Tsyvarev thanks for the reply.I added "message("C compiler: ${CMAKE_C_COMPILER}")" into my QNX.cmake then i came to know that compiler path in the tool chain was wrong and the path which i got from message() is "C compiler: home/mobis/qnx700/host/linux/x86_64/usr/bin/ntox86_64-gcc" After setting the above path also still i am getting the same error with new path ERROR: **--The C compiler identification is unknown CMake Error at CMakeLists.txt:7 (project) The CMAKE_C_COMPILER home/mobis/qnx700/host/linux/x86_64/usr/bin/ntox86_64-gcc is not a full path and was not found in the PATH** – sunny Jul 25 '19 at 00:49
  • Did you forgot the first `/` character in the path? – Tsyvarev Jul 25 '19 at 07:44
  • @Tsyvarev shame on me.yes had missed / now it is working.Thank you for the sopport. – sunny Jul 26 '19 at 00:45

0 Answers0