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

本文记录了在将tinydtls库从一个平台移植到openwrt平台时遇到的编译错误,并给出了详细的排查过程及解决方案。问题在于配置时传递的CFLAGS参数导致编译器无法创建可执行文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

主机:centos

SDK:openwrt(linux内核4.4.14)

编译工具: mipsel-openwrt-linux-gnu-gcc   5.3.0

今天在移植一个tinydtls库的时候,出现了一个让人头疼的问题。从一个平台移植到openwrt平台,之前的编译没问题。

就是在进入tinydtls编译目录编译时,在check编译器时,有打印信息如下:

checking for mipsel-openwrt-linux-gnu-gcc... mipsel-openwrt-linux-gnu-gcc
checking whether the C compiler works... no
configure: error: in `/home/lee/mt7621_router/openwrt/build_dir/target-mipsel_1004kc+dsp_glibc-2.22/tinydtls/tinydtls':
configure: error: C compiler cannot create executables
See `config.log' for more details

为了获得更详细的信息查看了config.log,关键的信息如下:

configure:2684: checking whether the C compiler works
configure:2706: mipsel-openwrt-linux-gnu-gcc " -Wl,--hash-style=sysv -fPIC "   conftest.c  >&5
mipsel-openwrt-linux-gnu-gcc: error: ": No such file or directory
mipsel-openwrt-linux-gnu-gcc: error: ": No such file or directory
configure:2710: $? = 1
configure:2748: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "tinydtls"
| #define PACKAGE_TARNAME "tinydtls"
| #define PACKAGE_VERSION "0.8.2"
| #define PACKAGE_STRING "tinydtls 0.8.2"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| /* end confdefs.h.  */
|
| int
| main ()
| {
|
|   ;
|   return 0;
| }
configure:2753: error: in `/home/lee/mt7621_router/openwrt/build_dir/target-mipsel_1004kc+dsp_glibc-2.22/tinydtls/tinydtls':
configure:2755: error: C compiler cannot create executables

表面上看,是由于找不到mipsel-openwrt-linux-gnu-gcc交叉编译工具而造成的,但是排查了这个情况,因为传下来的PATH中有编译工具文件夹的路径。

找了好几篇文章看了一下,其中有一篇文章里说传到./configure中的CFLAGS,LIBS变量的问题,我试了试./configure --host=$(CROSS_COMPILE_PRIV) CFLAGS=

这样就可以顺利的生成Makefile了。然后我看了一下之前传下来的CFLAGS=" -Wl,--hash-style=sysv -fPIC ",就是因为这个导致的。


参考文章链接:

1.http://blog.csdn.net/tyyhong/article/details/4266749 

2.http://blog.sina.com.cn/s/blog_533074eb01011yfv.html


评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值