ITKeyword,专注技术干货聚合推荐

注册 | 登录

64位Linux编译C代码,crt1.o文件格式不对的问题

gqtcgq 分享于 2016-03-16

2020腾讯云共同战“疫”,助力复工(优惠前所未有!4核8G,5M带宽 1684元/3年),
地址https://cloud.tencent.com/act/cps/redirect?redirect=1053

2020阿里云最低价产品入口,含代金券(新老用户有优惠),
地址https://www.aliyun.com/minisite/goods

今天在某台64位LInux下编译一个简单的hello world的C程序,报错:

/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../crt1.o: could not read symbols: File in wrong format

查看该文件的格式,竟然是32位的:

# file /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../crt1.o
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../crt1.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.18, not stripped

查看glibc-devel版本:

# yum info glibc-devel
Installed Packages
Name        : glibc-devel
Arch        : i686
Version     : 2.12
Release     : 1.149.el6_6.5
Size        : 955 k
Repo        : installed
From repo   : 6ASU5-updates
Summary     : Object files for development using standard C libraries.
URL         : http://sources.redhat.com/glibc/
License     : LGPLv2+ and LGPLv2+ with exceptions and GPLv2+
Description : The glibc-devel package contains the object files necessary
            : for developing programs which use the standard C libraries (which are
            : used by nearly all programs).  If you are developing programs which
            : will use the standard C libraries, your system needs to have these
            : standard object files available in order to create the
            : executables.
            : 
            : Install glibc-devel if you are going to develop programs which will
            : use the standard C libraries.

Available Packages
Name        : glibc-devel
Arch        : x86_64
Version     : 2.12
Release     : 1.149.el6_6.5
Size        : 983 k
Repo        : 6ASU5-updates
Summary     : Object files for development using standard C libraries.
URL         : http://sources.redhat.com/glibc/
License     : LGPLv2+ and LGPLv2+ with exceptions and GPLv2+
Description : The glibc-devel package contains the object files necessary
            : for developing programs which use the standard C libraries (which are
            : used by nearly all programs).  If you are developing programs which
            : will use the standard C libraries, your system needs to have these
            : standard object files available in order to create the
            : executables.
            : 
            : Install glibc-devel if you are going to develop programs which will
            : use the standard C libraries.



在其他正常的64位机器上,发现是有/usr/lib64/crt1.o文件的,而问题机器却没有改文件,只有/usr/lib/crt1.o文件。


询问牛人,牛人用了以下命令查看正常机器上的crt1.o文件:

# rpm -qf /usr/lib64/crt1.o 
glibc-devel-2.12-1.149.el6_6.5.x86_64

原来是问题机器只安装了glibc-devel.i686,没有安装glibc-devel.x86_64,用yum安装即可:

yum install glibc-devel.x86_64
安装成功后,一切正常!!!




今天在某台64位LInux下编译一个简单的hello world的C程序,报错: /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../crt1.o: could not read symbols: File in wrong format 查看该文件的格式

相关阅读排行


相关内容推荐

最新文章

×

×

请激活账号

为了能正常使用评论、编辑功能及以后陆续为用户提供的其他产品,请激活账号。

您的注册邮箱: 修改

重新发送激活邮件 进入我的邮箱

如果您没有收到激活邮件,请注意检查垃圾箱。