【已解决】configure: error: C++ compiler cannot create executables

发布时间 2023-04-03 11:49:02作者: 温泉镇谢步东

1.背景 

centos 7 在升级gcc

configure 的时候出现的问题

A100-01-$build#../configure --prefix=/usr/local/gcc --enable-threads=posix --disable-checking --disable-multilib --enable-languages=c,c++
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... /usr/bin/sed
checking for gawk... gawk
checking for libatomic support... yes
checking for libitm support... yes
checking for libsanitizer support... yes
checking for libvtv support... yes
checking for libhsail-rt support... yes
checking for libphobos support... yes
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/home/work/gcc-10.1.0/build':
configure: error: C compiler cannot create executables
See `config.log' for more details

 

2.网上的解决方法

2.1 安装gcc  没有用

2.2 清空环境变量里的 libs 和cflags  没有用

export LIBS=

export CFLAGS=

 

3. 我的解决方法 

# 就是查找config.log 里缺少啥
grep cannot config.log

# 输出如下
# as
: error while loading shared libraries: libopcodes-2.27-44.base.el7.so: cannot open shared object file: No such file or directory # configure:4536: error: C compiler cannot create executables

# 查看本地 lib64
ll /usr/lib64|grep libopcodes

  # -rwxr-xr-x.  1 root root   1686656 11月  1 2021 libopcodes-2.27-44.base.el7_9.1.so

# 果然没有
# 然后从其他机器上复制了一个过来
scp a03:/usr/lib64/libopcodes-2.27-44.base.el7.so /usr/lib64/