我将CMake与QNX Momentics一起使用。为此,我执行了命令
cmake -DCMAKE_TOOLCHAIN_FILE=/my-path/qnx.cmake
在终端上显示了以下提到的错误:
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."
我已经在本地计算机中检查了ntox86_64-gcc
编译器,并且该编译器位于/hom/Test/host/linux/x86_64/usr/bin
位置。
我试图通过使用CMake在命令行中提供编译器路径来进行构建,但它显示出相同的错误。
即使遇到相同的错误,也尝试过以下解决方案:
CMAKE_C_COMPILER is not a full path to an existing compiler tool
export CC=/usr/bin/gcc
export CXX=/usr/bin/g++
请在我的 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)
请在我的 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})
预期: