CentOS 交叉编译报 configure: error: cannot run C compiled programs.

一禅(OneZen) 2014-05-05 09:36:20
CentOS 交叉编译报 错,求解决办法 安装需要编译的软件,都会出现这样的错误。

系统是:CentOS 6.X


[root@localhost ruby-2.1.1]# ./configure
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... configure: error: in `/usr/local/rvm/src/ruby-2.1.1':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.这里提示用本机
See `config.log' for more details



[root@localhost ruby-2.1.1]# ./configure --host =x86_64-unknown-linux-gnu
checking for clockid_t... no
checking for convertible type of clockid_t... INT
checking for prototypes... yes
checking token paste string... ansi
checking stringization... #expr
checking string literal concatenation... yes
checking for variable length prototypes and stdarg.h... yes
checking for variable length macro... yes
checking for noreturn function attribute... __attribute__ ((noreturn)) x
checking for deprecated function attribute... __attribute__ ((deprecated)) x
checking for noinline function attribute... __attribute__ ((noinline)) x
checking for stdcall function attribute... x
checking for cdecl function attribute... x
checking for fastcall function attribute... x
checking for function alias... alias
checking for __atomic builtins... no
checking for __sync builtins... yes
checking for __builtin_unreachable... no
checking for exported function attribute... __attribute__ ((visibility("default")))
checking for function name string predefined identifier... no
checking whether sys_nerr is declared... no
checking whether getenv is declared... no
checking for size_t... no
configure: error: size_t is signed 报这个错误
...全文
10811 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
allen519 2016-08-08
  • 打赏
  • 举报
回复
我今天 在 做lfs 6.3的 gcc 编译的时候遇到了这个问题 但不是 2楼说的 这种情况
zhxianbin 2015-02-04
  • 打赏
  • 举报
回复 1
http://www.cppblog.com/iuranus/archive/2011/07/22/151615.html ./configure -build,-host,-target设置 build:执行代码编译的主机,正常的话就是你的主机系统。这个参数一般由config.guess来猜就可以。当然自己指定也可以。 host:编译出来的二进制程序所执行的主机,因为绝大多数是如果本机编译,本机执行。所以这个值就等于build。只有交叉编译的时候(也就是本机编译,其他系统机器执行)才会build和host不同。用host指定运行主机。 target:这个选项只有在建立交叉编译环境的时候用到,正常编译和交叉编译都不会用到。他用build主机上的编译器,编译一个新的编译器(binutils, gcc,gdb等),这个新的编译器将来编译出来的其他程序将运行在target指定的系统上。 让我们以编译binutils为例: 1. `./configure --build=mipsel-linux --host=mipsel-linux --target=mipsel-linux' 说明我们利用mipsel-linux的编译器对binutils进行编译,编译出来的binutils运行在mipsel-linux,这个binutils用来编译能够在mipsel-linux运行的代码。“当然没有人会用这个选项来编译binutils” 2. `./configure --build=i386-linux --host=mipsel-linux --target=mipsel-linux' will cross-build native mipsel-linux binutils oni386-linux. 说明我们利用i386-linux的编译器对binutils进行编译,编译出来的binutils运行在mipsel-linux,这个binutils用来编译能够在mipsel-linux运行的代码。“这个选项可以用来为其他的机器编译它的编译器”。 3. `./configure --build=i386-linux --host=i386-linux --target=mipsel-linux' will build mipsel-linux cross-binutils on i386-linux. 说明我们利用i386-linux的编译器对binutils进行编译,编译出来的binutils运行在i386-linux,这个binutils用来编译能够在mipsel-linux运行的代码。“这个选项用来在i386主机上建立一个mipsel-linux的交叉编译环境”。 4. `./configure --build=mipsel-linux --host=i386-linux --target=mipsel-linux' will cross-build mipsel-linux cross-binutils for i386-linux on mipsel-linux. 说明我们利用mipsel-linux的编译器对binutils进行编译,编译出来的binutils运行在i386-linux,这个binutils用来编译能够在mipsel-linux运行的代码。“这个选项可以用来在i386主机上建立一个mipsel-linux的交叉编译环境,但是交叉编译环境在mipsel-linux 编译出来,安装到i386-linux主机上,估计没有多少人会这么用吧” 总的来说,只有host !=build的时候编译才是交叉编译。否则就是正常编译。
liuwenxiang110120 2015-02-04
  • 打赏
  • 举报
回复
2楼正解
fly 100% 2014-10-17
  • 打赏
  • 举报
回复
指明编译适配主机的类型
action_tmp 2014-09-23
  • 打赏
  • 举报
回复
同问为什么加--host=x86_64可以解决?
xlhl3 2014-08-31
  • 打赏
  • 举报
回复
这到底是什么原因哦? 为什么加个 --host=xxx 就能成功哦?
tonyzhang828 2014-08-13
  • 打赏
  • 举报
回复
error: cannot run C compiled programs 这个报错只要在编译参数最后加上 --host=x86_64即可 uname -m 这个命令可以看相关信息
一禅(OneZen) 2014-05-05
  • 打赏
  • 举报
回复
下面的组件都安装与更新了 gcc 4.1.2-44.el5 binutils 2.17.50.0.6-9.el5 cpp 4.1.2-44.el5 glibc-devel 2.5-34.el5_3.1 glibc-headers 2.5-34.el5_3.1 kernel-headers 2.6.18-164.el5 libgomp 4.3.2-7.el5

4,436

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 内核源代码研究区
社区管理员
  • 内核源代码研究区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧