CMake 找不到编译器,但它在 PATH 中

问题描述 投票:0回答:0

我正在尝试构建一个交叉编译的 CMake 项目,但找不到编译器。这是我看到的消息:

-- Architecture = arm
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/cc
-- The C compiler identification is GNU 11.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- The CXX compiler identification is GNU 10.3.1
CMake Error at CMakeLists.txt:7 (project):
  The CMAKE_C_COMPILER:

    arm-none-eabi-gcc

  is not a full path and was not found in the PATH.

  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.

如前一条消息所说,如果我的编译器在

PATH
中,应该可以找到:

或编译器名称(如果它在 PATH 中)。

我用的编译器(arm-gcc)确实在

PATH
。如果我添加指令
message(FATAL_ERROR "++++++++++++++ $ENV{PATH}")
我得到:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/opt/gcc-arm-none-eabi-10.3-2021.10/bin

最后一个路径,

/opt/gcc-arm-none-eabi-10.3-2021.10/bin
,包含一个arm-gcc编译器:

$ls -l /opt/gcc-arm-none-eabi-10.3-2021.10/bin
total 62496
...
-rwxr-xr-x 2 1001 1001  1301072 Oct 18  2021 arm-none-eabi-g++
-rwxr-xr-x 2 1001 1001  1296976 Oct 18  2021 arm-none-eabi-gcc
...

cmake
怎么没找到?我做错了什么?

linux cmake toolchain
© www.soinside.com 2019 - 2024. All rights reserved.