一. 前言

在编译开源软件的时候,有时会遇到"configure: error: C compiler cannot create executables"的错误,表示不能生成可执行文件。本文以编译curl-7.40.0为例,模拟出这种错误,并讲解解决这种错误的方法。错误输出如下:

[root@192 curl-7.40.0]# ./configure LIBS=-lopenssl
checking whether to enable maintainer-specific portions of Makefiles... no
checking whether to enable debug build options... no
checking whether to enable compiler optimizer... (assumed) yes
checking whether to enable strict compiler warnings... no
checking whether to enable compiler warnings as errors... no
checking whether to enable curl debug memory tracking... no
checking whether to enable hiding of library internal symbols... yes
checking whether to enable c-ares for DNS lookups... no
checking for path separator... :
checking for sed... /usr/bin/sed
checking for grep... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ar... /usr/bin/ar
checking for a BSD-compatible install... /usr/bin/install -c
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/home/betterman/opensource/curl-7.40.0':
configure: error: C compiler cannot create executables
See `config.log' for more details

二. 错误解析

根据最后一句输出,我们需要参考config.log的内容。从config.log文件中,可以找到如下一段内容:

configure:4216: checking whether the C compiler works
configure:4238: gcc    conftest.c -lopenssl >&5                   (1)
/usr/bin/ld: cannot find -lopenssl                                          (2)
collect2: error: ld returned 1 exit status
configure:4242: $? = 1
configure:4280: result: no
configure: failed program was:
| /* confdefs.h */                                                                    (3)
| #define PACKAGE_NAME "curl"
| #define PACKAGE_TARNAME "curl"
| #define PACKAGE_VERSION "-"
| #define PACKAGE_STRING "curl -"
| #define PACKAGE_BUGREPORT "a suitable curl mailing list: http://curl.haxx.se/mail/"
| #define PACKAGE_URL ""
| /* end confdefs.h.  */

| int main (void)
| {

|  ;
|  return 0;
| }
configure:4285: error: in `/home/wenyong/opensource/curl-7.40.0':
configure:4287: error: C compiler cannot create executables                (4)
See `config.log' for more details

从(1)可知,gcc会编译conftest.c文件并且需要链接libopenssl.so,所以报(2)的错误,表示编译时找不到libopenssl.so库,conftest.c的内容是从(3)开始,最后产生了(4)处的错误。

三. 解决方法

由上可知,可以得出结论:软件包在configure的时候,configure会根据用户指定的编译选项编译conftest.c文件,由此来预检查编译时要用到的gcc,动态库等是否可以找到,尽早让用户检查错误。

本例的错误是由于libopenssl.so找不到,所以解决方法有:

1. 通过LDFLAGS选项指定libopenssl.so所在的路径,例如:

./configure LIBS=-lopenssl LDFLAGS=/root/libopenssl/usr/lib

2. 直接使用./configure编译

如果编译curl不需要用到openssl的库,可以不链接。

四. 总结

本文讲解了解决"configure: error: C compiler cannot create executables"问题出现的原因与解决的思路:configure运行的时候需要使用用户指定的选项编译conftest.c文件,但是由于选项指定的gcc或动态库找不到,导致编译报错,解决的方法是指定gcc和动态库的路径。

configure: error: C compiler cannot create executables错误解析相关推荐

  1. linux 编译错误 configure: error: C++ compiler cannot create executables

    今天装虚拟机LNMP环境 安装报错:configure: error: C++ compiler cannot create executables 这是因为 gcc 组件不完整,执行安装 yum i ...

  2. 编译问题configure: error: C compiler cannot create executables

    主机:centos SDK:openwrt(linux内核4.4.14) 编译工具: mipsel-openwrt-linux-gnu-gcc   5.3.0 今天在移植一个tinydtls库的时候, ...

  3. sqlite3 交叉编译出现configure: error: C compiler cannot create executables

    解决办法是:在配置交叉编译器的条件下,不要复制,手动输入就可以解决 参考博客: https://blog.csdn.net/xiongzhizhu/article/details/52372655

  4. C compiler cannot create executables问题

    今天在装advancemame游戏时遇到下面的问题,在网上搜索才知道是gcc没有装好,回想以前也有一些程序没有装好,是不是也是这个问题呢?于是试了一下以前一直没有装好的d4x,虽然现在熟悉了wget. ...

  5. configure报错C compiler cannot create executables

    这个错直译过来就是编译器无法编译 首先检查打印的编译器路径能否执行,是否存在,发现存在,不是路径问题 看config.log里面的详细打印,检查出错的地方 截取部分日志,先检查了$(CC) -V -- ...

  6. 升级 GCC 支持C++11 或 configure: error: *** A compiler with support for C++11 language features is requir

    升级 GCC 支持C++11 或 configure: error: *** A compiler with support for C++11 language features is requir ...

  7. configure: error: C compiler cc is not found

    问题描述 编译安装nginx ./configure遇到错误,C compiler cc is not found 但是gcc和cc命令都已经安装/usr/bin/gcc和./usr/bin/cc 编 ...

  8. Linux报错./configure: error: C compiler cc is not found

    yum -y install gcc gcc-c++ autoconf automake make

  9. ERROR tool.ExportTool: Error during export: Export job failed!错误解析

    在使用sqoop导出数据的时候出现了这种报错. 20/08/27 15:03:05 ERROR tool.ExportTool: Error during export: Export job fai ...

最新文章

  1. Windows Forms高级界面组件-快捷菜单
  2. 《SAP CRM管理与实施指南》一一2.3 小结
  3. Google BERT模型提取句子Token特征
  4. 数据库中查询记录时是否每次只能使用一个索引?
  5. CodeForces - 137D Palindromes(dp+路径输出)
  6. BigDecimal类整除报错的解决方案
  7. 这不仅仅是html5的HTML5问题
  8. 【AI视野·今日NLP 自然语言处理论文速览 第二十八期】Wed, 1 Dec 2021
  9. MYSQL优化派生表(子查询)在From语句中的
  10. PS5国行版本周六开售 索尼:PS5将缺货至明年
  11. activiti6使用
  12. vue05-REST 请求
  13. ubuntu中eclipse无法识别android手机问题
  14. 360保存html,360极速浏览器怎么保存网页为图片?
  15. 阿里 酷家乐:实习生面试
  16. 3dmax测试软件自动关闭,打开3dmax出现软件问题导致3dmax意外关闭的两种解决方法...
  17. kron matlab_使用kron来实现repmat, repelem的功能
  18. 云平台之实例类型与故障迁移
  19. 2018清明假期旅游预测报告:全国游客人次预计破亿
  20. 51单片机洞洞板用的visio图_万能洞洞板之单片机DIY设计,开启制作之路-可编程逻辑-与非网...

热门文章

  1. 查看磁盘是ssd还是hdd
  2. AQS中公平锁和非公平锁的区别
  3. 知乎里那些绝美的壁纸在这里!
  4. Linux 音频驱动(二) ASoC音频驱动之Platform驱动
  5. 黑客词典:什么是全盘加密
  6. 计算机理想开启美好人生作文,“理想开启美好人生”的作文,急需
  7. [论文解读]CNN 卷积的魅力+特征图+感受野+共享权重和偏置
  8. 如何一键制作世界顶级音质的DVD Audio碟片?
  9. python红楼梦_用Python读红楼
  10. 百度AI人脸识别与检测一:学生人脸识别签到系统简介及百度AI开放平台账号注册和人脸实例应用创建