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

安装pcre时出现configure: error: C compiler cannot create executables错误这种编译不通过问题 大致是两方面造成的 一方面可能是 gcc 的问题 一般是 gcc 缺少 链接不对 或者版本不对 过低或过高 有可能是在装其他软件时候 gcc 被无意破坏过 或者系统是 mini 版的 相关配置不全等造成的 这时候如果可以 最好重装对应版本的 gcc 即可解决 另一方面可能是要安装的软件缺少相关依赖包 导致编译不通过 这时候要先安装缺少的依赖 全部依赖包或者依赖软件安装完后 执行 conf

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

一方面可能是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

 

 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/211099.html原文链接:https://javaforall.net

(0)
上一篇 2026年3月18日 下午11:13
下一篇 2026年3月18日 下午11:13


相关推荐

  • 2026年Word文档转公众号总是格式混乱?快速排版文章最新完整指南

    2026年Word文档转公众号总是格式混乱?快速排版文章最新完整指南

    2026年3月17日
    2
  • 嵌入式软件工程师待遇怎么样

    嵌入式软件工程师待遇怎么样本来大家选择嵌入式也就是冲着嵌入式的发展前景不错而来,所以在嵌入式这块还是有很多不知道的知识,这些也都要等着老师去给你讲解了,下面先来了解下嵌入式软件工程师待遇怎么样吧。嵌入式软件工程师待遇怎么样:1、应届毕业生如果你是在一线城市的话,有人带你,你自己有比较学的好,那么你的薪资待遇就可以达到6k+,但是不同公司不同待遇,而且不同地区不同的薪资待遇,就像北上广,这些地区薪资待遇是比其他地区高出2k以上,甚至更高的。就像人家阿里,那工资肯定就比其他公司要高的多。所以得看你要去什么地方发展了,但是平均

    2025年11月20日
    5
  • 使用python+flask让你自己api(教程源代码)

    使用python+flask让你自己api(教程源代码)

    2022年1月9日
    39
  • Openclaw 集成 Discord 教程+避坑

    Openclaw 集成 Discord 教程+避坑

    2026年3月13日
    2
  • 权限持久化—映像劫持检测(Shift后门)[通俗易懂]

    权限持久化—映像劫持检测(Shift后门)[通俗易懂]映像劫持说白了还是利用了windows的一些特性,当你点击可执行文件进行执行时,系统并不会直接就对可执行文件进行执行,而是首先对注册表的HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\ImageFileExecutionOptions,这个路径下面如果存在和该程序名称完全相同的子键,就查询对应子健中包含的“Dubugger”键值名,并用其指定的程序路径来代替原始的程序,之后执行的是遭到“劫持”的虚假程序。比较常用的是.

    2025年12月16日
    1
  • HTML与XML的区别(转)

    什么是HTML  HTML的全拼是Hypertext Markup Language, 中文也就是超文本链接标示语言。HTML(HyperTextMark-upLanguage)即超文本标记语言,是WWW的描述语言。设计HTML语言的目的是为了能把存放在一台电脑中的文本或图形与另一台电脑中的文本或图形方便地联系在一起,形成有机的整体,人们不用考虑具体信息是在当前电脑上还是在网络的其它电脑上。我们只需

    2022年2月25日
    56

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号