CentOS 7 devtoolset编译addressSanitizer版本失败的问题解决

在我的一个Cent OS7开发环境中,按https://yeyongjin.blog.csdn.net/article/details/134178420的方法升级GCC版本到8.3.1。

这两天,要用Google的addressSanitizer检验内存问题,加上编译参数后,却发现编译不通过。configure时直接退出,检查config.log,发现有这样的内容:

configure:5166: checking whether the C compiler works

configure:5188: gcc -I${INSTALL_DIR}/include -g -O0 -fsanitize=address -fno-omit-frame-pointer conftest.c >&5

/opt/rh/devtoolset-8/root/usr/libexec/gcc/x86_64-redhat-linux/8/ld: cannot find libasan_preinit.o: No such file or directory

/opt/rh/devtoolset-8/root/usr/libexec/gcc/x86_64-redhat-linux/8/ld: cannot find -lasan

collect2: error: ld returned 1 exit status

显然,在编译检测时,发现ibasan连接时找不到文件。

检查一下系统里的安装情况:

复制代码
 rpm -qa | grep asan

显示:

系统是有安装libasan的,但是版本和devtoolset版本不同。

解决方法:安装devtoolset对应的版本:

复制代码
yum install devtoolset-8-libasan-devel

安装完毕后,重新编译就成了。

相关推荐
遇见火星4 天前
Linux 网络配置实战:RHEL/CentOS 7+ 永久静态路由配置与优先级调整全攻略
linux·网络·centos·静态路由·centos 7
howard200512 天前
CentOS 7上运行C程序
centos 7·c程序
代码一天不写我浑森蓝廋12 天前
CentOS7 使用 centos-release-scl-rh yum库安装 devtoolset
linux·centos·gcc·devtoolset
howard200513 天前
CentOS 7上编写C程序访问MySQL数据表
c·centos 7·mysql 8.0.43
cnskylee5 个月前
【Keepalived】Keepalived-2.3.4 已恢复对 CentOS 7 支持
centos 7·keepalied 2.3.4·rhel 7
shylyly_6 个月前
Linux环境基础开发工具->vim
linux·运维·编辑器·vim·centos 7·vim配置·底行模式
__雨夜星辰__9 个月前
Linux 学习笔记__Day2
linux·服务器·笔记·学习·centos 7
Mr.caesar1 年前
CentOS7使用yum命令报错
yum·centos 7·yum命令报错
梦幻加菲猫2 年前
CentOS 7静默安装Oracle 11g(记一次最小化CentOS 7安装Oracle 11g的经历)
oracle·静默安装·centos 7