CLion CMake:arm-none-eabi-g++:尝试执行“cc1plus”时出错:execvp:没有此文件或目录

CLion CMake:arm-none-eabi-g++:尝试执行“cc1plus”时出错:execvp:没有此文件或目录

我已经为此苦苦挣扎了大约 2 天,但似乎找不到解决方案。我最近换了一台新笔记本电脑并安装了 Ubuntu 19.04,现在我的 c++ 编译器出现了一些问题。我正尝试使用 GNU 编译器在 CLion 中加载 CMakeLists.txt 文件这里,但我不断收到以下错误消息:

-- Add a local project.cmake file to add your own targets.
-- Configuring done
You have changed variables that require your cache to be deleted.
Configure will be re-run and you may have to reset some variables.
The following variables have changed:
CMAKE_C_COMPILER= /usr/bin/arm-none-eabi-gdb

-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/arm-none-eabi-gcc

最后是这些行:

arm-none-eabi-g++: error trying to exec 'cc1plus': execvp: No such file or directory

arm-none-eabi-gcc: error trying to exec 'cc1': execvp: No such file or directory

在我的旧(可以使用的)笔记本电脑上显示:

-- The C compiler identification is GNU 6.3.1
-- The CXX compiler identification is GNU 6.3.1
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/arm-none-eabi-gcc

我查看了很多论坛帖子,但还是无法让它工作。我尝试了很多方法,包括:

sudo apt-get install --reinstall build-essential

以下命令:

g++ --print-prog-name=cc1plus

返回:

/usr/lib/gcc/x86_64-linux-gnu/8/cc1plus

和这个:

which arm-none-eabi-g++

返回:

/usr/bin/arm-none-eabi-g++

但:

which cc1plus

不返回任何内容。


我觉得应该有一个简单的修复方法,将 CLion 指向正确的 cc1 编译器,但工具链设置与我工作的笔记本电脑上的相同,但新的 CLion 不起作用。任何帮助都非常感谢。

杰克



编辑:

这是 CMake 的设置方式

CMAKE_MINIMUM_REQUIRED(VERSION 3.9)
SET(CMAKE_SYSTEM_NAME Generic)
#SET(CMAKE_SYSTEM_PROCESSOR arm)
SET(CMAKE_CROSSCOMPILING TRUE)

# force compiler settings
SET(CMAKE_C_COMPILER_WORKS TRUE)
SET(CMAKE_CXX_COMPILER_WORKS TRUE)

# force cmake compilers
SET(CMAKE_ASM_COMPILER    "arm-none-eabi-gcc")
SET(CMAKE_C_COMPILER      "arm-none-eabi-gcc")
SET(CMAKE_CXX_COMPILER    "arm-none-eabi-g++")
SET(ELF2BIN               "arm-none-eabi-objcopy")


# if the environment does not specify build type, set to Debug
IF(NOT CMAKE_BUILD_TYPE)
  set(CMAKE_BUILD_TYPE "Debug"
        CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
        FORCE)
ENDIF()

相关内容