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

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

相关推荐
梦幻加菲猫2 个月前
CentOS 7静默安装Oracle 11g(记一次最小化CentOS 7安装Oracle 11g的经历)
oracle·静默安装·centos 7