遇到No CMAKE_CXX_COMPILER could be found.问题

遇到的问题

No CMAKE_CXX_COMPILER could be found.

Tell CMake where to find the compiler by setting either the environment
variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
to the compiler, or to the compiler name if it is in the PATH.

分析

1.查看g++有没有安装?(我的是g++没安装

which g++

2.没有就安装g++

sudo apt install g++ -y

(一般都是g++和cmake,gcc一起安装)

sudo apt install gcc g++ cmake -y

3.要是g++安装有问题,就是apt的源有问题。

我的就是apt的源有问题,导致g++安装失败。

 

4.更换apt源:

我的环境是ARM的Ubuntu 18.04 

4.1 备份源

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

4.2 编辑

sudo vim /etc/apt/sources.list

4.3写入内容为:

# 中科大源 - ubuntu18.04 - arm构架 【Nvidia Jetson】
deb https://mirrors.ustc.edu.cn/ubuntu-ports/ bionic main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu-ports/ bionic main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-proposed main restricted universe multiverse

 

4.4更换apt源参考:

https://www.cnblogs.com/liqi175/p/16565517.html

 

5.再次安装g++

sudo apt install gcc g++ cmake -y

成功!

我的可以编译了!!

 

 

 

 

参考资料:

g++的问题:https://blog.csdn.net/weixin_44120025/article/details/118769262

ARM源:https://zhuanlan.zhihu.com/p/618725243

 

 
posted @ 2023-04-18 16:19  o蹲蹲o  阅读(1485)  评论(0编辑  收藏  举报