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

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,发现开始报错处:/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

 

 

你可能感兴趣的:(pcre,Linux)