zl程序教程

您现在的位置是:首页 >  其他

当前栏目

安装pcre时出现configure: error: C compiler cannot create executables错误

错误安装 Error 出现 Cannot create configure compiler
2023-09-27 14:28:03 时间

这种编译不通过问题,大致是两方面造成的:

一方面可能是gcc的问题,一般是gcc缺少(链接不对)或者版本不对(过低或过高)。有可能是在装其他软件时候gcc被无意破坏过,或者系统是mini版的,相关配置不全等造成的。这时候如果可以,最好重装对应版本的gcc即可解决。

另一方面可能是要安装的软件缺少相关依赖包,导致编译不通过。这时候要先安装缺少的依赖,全部依赖包或者依赖软件安装完后,执行configure一般就没问题了。

错误结果一样,但可能导致问题的原因不同,还得具体问题具体分析。但是大家遇到类似问题,一般朝以上两方面考虑即可。


 下边是我遇到的问题及解决过程,希望对遇到类似问题的小伙伴有帮助 

1、./configure时出现以下错误C compiler cannot create executables

[root@insight pcre-8.39]# ./configure 
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/opt/software/pcre-8.39':
configure: error: C compiler cannot create executables
See `config.log' for more details

2、于是查看日志config.log,发现第7行开始报错处:/usr/bin/ld: cannot find -lgcc_s,就是编译时在/usr/lib/gcc/x86_64-redhat-linux/4.4.7/libgcc_s.so找不到lgcc_s,说明libgcc_s.so有问题。 

gcc: no input files
configure:3809: $? = 1
configure:3829: checking whether the C compiler works
configure:3851: gcc    conftest.c  >&5
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.4.7/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.4.7/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
collect2: ld returned 1 exit status
configure:3855: $? = 1
configure:3893: result: no
configure: failed program was:
|................
| int
| main ()
| {
|   ;
|   return 0;
| }
configure:3898: error: in `/opt/software/pcre-8.39':
configure:3900: error: C compiler cannot create executables
See `config.log' for more details

3、查看报错的机器 $ ls -l /usr/lib/gcc/x86_64-redhat-linux/4.4.7/libgcc_s.so,显示如下

[root@insight pcre-8.39]# ls -l /usr/lib/gcc/x86_64-redhat-linux/4.4.7/libgcc_s.so
-rwxr-xr-x. 1 root root 24 May 18  2018 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/libgcc_s.so

而去另一台完好的机器查看 $ ls -l /usr/lib/gcc/x86_64-redhat-linux/4.4.7/libgcc_s.so,显示如下

[root@node02 ~]# ls -l /usr/lib/gcc/x86_64-redhat-linux/4.4.7/libgcc_s.so
lrwxrwxrwx. 1 root root 24 May 18  2018 /usr/lib/gcc/x86_64-redhat-linux/4.4.7/libgcc_s.so -> /usr/lib64/libgcc_s.so.1

即发现libgcc_s.so是一个链接文件,对应的真实路径在 /usr/lib64/libgcc_s.so.1,需要为libgcc_s.so添加链接指向 

4、于是在报错的机器查找 $ find / -name libgcc_s.so1,可以看到就在/usr/lib64/libgcc_s.so.1下(64位机)

[root@insight pcre-8.39]# find / -name libgcc_s.so.1
/opt/oracle/app/oracle/product/11.2.0/dbhome_1/lib/stubs/libgcc_s.so.1
/root/libgcc_s.so.1
/lib/libgcc_s.so.1
/usr/lib/vmware-tools/lib32/libgcc_s.so.1
/usr/lib/vmware-tools/lib32/libgcc_s.so.1/libgcc_s.so.1
/usr/lib/vmware-tools/lib64/libgcc_s.so.1
/usr/lib/vmware-tools/lib64/libgcc_s.so.1/libgcc_s.so.1
/usr/lib64/libgcc_s.so.1
/lib64/libgcc_s.so.1 

没错,就是因为某种原因我们无意破换了libgcc_s.so链接指向,因此需要为libgcc_s.so重新指向对应路径

$ ln -sf /usr/lib64/libgcc_s.so.1  /usr/lib/gcc/x86_64-redhat-linux/4.4.7/libgcc_s.so

好了,再次$ ./configure下,刚才的错误没有了,问题解决

pcre-8.39 configuration summary:

    Install prefix .................. : /usr/local
    C preprocessor .................. : gcc -E
    C compiler ...................... : gcc
    C++ preprocessor ................ : g++ -E
    C++ compiler .................... : g++
    Linker .......................... : /usr/bin/ld -m elf_x86_64
    C preprocessor flags ............ : 
    C compiler flags ................ : -g -O2 -fvisibility=hidden
    C++ compiler flags .............. : -O2 -fvisibility=hidden -fvisibility-inlines-hidden
    Linker flags .................... : 
    Extra libraries ................. : 

    ...................................
    Buffer size for pcregrep ........ : 20480
    Link pcregrep with libz ......... : no
    Link pcregrep with libbz2 ....... : no
    Link pcretest with libedit ...... : no
    Link pcretest with libreadline .. : no
    Valgrind support ................ : no
    Code coverage ................... : no