clion疑难问题解决-升级cmake&gdb
最近使用Clion链接远程主机时,总是遇到c++ 语言版本太低的问题,即使 添加
-std=c++11
这个问题仍然存在,多方查找,发现问题出在cmake 和gdb版本太低,寻找了两篇对应安装教程,以作记录。
cmake升级
1、各种cmake版本安装包下载
Cmake Files Download:https://cmake.org/files/
2、安装教程参考
我使用sudo apt-get install cmake默认安装的是3.10.2,我们这里编译要求cmake的版本至少是3.13以上
卸载旧版本的cmake
apt-get autoremove cmake
最好不要用上面的命令,直接把旧版本cmake所在的目录删除或移动到桌面备份也可以
上面的傻逼命令,会把之前安装的ros很多库包都删除了,以后如果要卸载什么包,最好用命令:sudo apt remove package_name,atutoremove命令不要轻易用
sudo rm -rf /usr/bin/cmake
注意:
旧版本的cmake可以不用卸载的,所以上面的命令也可以不用使用,因为我在卸载旧版本的cmake的时候,它自动把好多依赖都卸载了,把我的ROS系统也卸载了,哎,只想说FK!
3、下载cmake的安装包,这里我下载的是3.16.8
wget https://cmake.org/files/v3.16/cmake-3.16.8-Linux-x86_64.tar.gz
注意:
cmake-3.16.8-Linux-x86_64.tar.gz压缩包里的文件是已经编译过的,解压就可以用!
4、解压
tar zxvf cmake-3.16.8-Linux-x86_64.tar.gz
5、建立软链接
sudo ln -s /home/shl/tools/cmake-3.16.8-Linux-x86_64/bin/cmake /usr/bin/cmake
软链接建立成功,就可以使用cmake了
(base) shl@zhihui-mint:~/tools$ sudo ln -s /home/shl/tools/cmake-3.16.8-Linux-x86_64/bin/cmake /usr/bin/cmake<br>(base) shl@zhihui-mint:~/tools$ cmake --version<br>cmake version 3.16.8
CMake suite maintained and supported by Kitware (kitware.com/cmake).<br>(base) shl@zhihui-mint:~/tools$
————————————————
gdb升级
1、yum安装
<br>[root@s142 gdb-7.8]# yum install -y gdb
2、查看gdb版本
[root@s142 gdb-7.8]# gdb -v
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-120.el7
Copyright © 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
…
三、升级步骤<br>1、下载待升级的gdb版本<br>[root@s142 opt]# wget http://ftp.gnu.org/gnu/gdb/gdb-7.8.tar.gz
2、解压软件包
[root@s142 opt]# tar -zxvf gdb-7.8.tar.gz
3、修改授权
[root@s142 opt]# chown -R root.root gdb-7.8
4、预编译
[root@s142 gdb-7.8]# mkdir build
[root@s142 build]# …/configure --prefix=/usr
…
configure: creating ./config.status
config.status: creating Makefile
5、编译
遇到预编译或者编译报错,请参照QA章节处理。
[root@s142 build]# make
make[4]: Leaving directory /opt/gdb-7.8/build/gdb/build-gnulib’ make[3]: Leaving directory
/opt/gdb-7.8/build/gdb’
make[2]: Leaving directory /opt/gdb-7.8/build/gdb’ make[1]: Nothing to be done for
all-target’.
make[1]: Leaving directory `/opt/gdb-7.8/build’
6、编译安装
[root@s142 build]# make install
…
make[2]: Leaving directory /opt/gdb-7.8/build/gdb’ make[1]: Nothing to be done for
install-target’.
make[1]: Leaving directory `/opt/gdb-7.8/build’
7、查看升级后的版本
[root@s142 build]# gdb -v
GNU gdb (GDB) 7.8
四、QA
1、预编译的时候报错no acceptable C compiler found in $PATH
报错信息:configure: error: no acceptable C compiler found in $PATH
报错原因:未安装gcc
解决方案:yum install -y gcc*
2、make的时候报错[all-bfd] Error
报错信息:make[3]: *** [bfd.info] Error 1
报错原因:没有安装texinfo模块
解决方案:yum install -y texinfo,然后重新执行预编译步骤
3、make的时候报错
报错信息:no termcap library found
报错原因:没有安装termcap
解决方案:源码安装termcap
下载termcap软件包
[root@s142 opt]# wget https://ftp.gnu.org/gnu/termcap/termcap-1.3.1.tar.gz --no-check-certificate
解压软件包
[root@s142 opt]# tar -zxvf termcap-1.3.1.tar.gz
修改属主
[root@s142 opt]# chown -R root.root termcap-1.3.1
预编译
[root@s142 termcap-1.3.1]# ./configure --prefix=/usr
编译
[root@s142 termcap-1.3.1]# make
编译安装
[root@s142 termcap-1.3.1]# make install
参考链接
- https://blog.csdn.net/weixin_41010198/article/details/109343347
- https://blog.csdn.net/carefree2005/article/details/125068985