64位Linux编译错误:could not read symbols: File in wrong format

在Centos 6.5 64位 机器上编译一个 64位 程序时,出现错误:

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

可以看到,编译器对应到了 32位 lib目录下

尝试解决

  1. 查看 crt1.o 文件格式:

    # 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

    32位

  2. 查看 crt1.o 文件的所属安装包:

    # rpm -qf /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../crt1.o
    glibc-devel-2.12-1.212.el6.i686

    是属于 32位glibc-devel 开发包

  3. 查看 glibc-devel 的安装情况

    # yum list glibc-devel
    Loaded plugins: fastestmirror, refresh-packagekit, security
    Loading mirror speeds from cached hostfile
    * base: mirrors.aliyun.com
    * extras: mirrors.aliyun.com
    * updates: mirrors.huaweicloud.com
    Installed Packages
    glibc-devel.i686                2.12-1.212.el6             @base
    Available Packages
    glibc-devel.i686                2.12-1.212.el6_10.3        updates
    glibc-devel.x86_64              2.12-1.212.el6_10.3        updates

    可以看到,只安装了 32位,而没有安装 64位glibc-devel

  4. 安装 64位 glibc-devel:

    # yum install glibc-devel.x86_64
  5. 完成后,重新编译 64位 程序,一切正常!

0 0 投票数
喜欢就给个好评吧!
赞(0) 打赏
未经允许不得转载:爱易默博客 » 64位Linux编译错误:could not read symbols: File in wrong format
订阅评论
提醒
guest

0 评论
最旧
最新 最多投票
内联反馈
查看所有评论
免责声明:本站大部分下载资源收集于网络,只做学习和交流使用,版权归原作者所有,请在下载后24小时之内自觉删除,若作商业用途,请购买正版,由于未及时购买和付费发生的侵权行为,与本站无关。本站发布的内容若侵犯到您的权益,请联系站长删除,我们将及时处理! Disclaimer: Most of the download resources on this site are collected on the Internet, and are only used for learning and communication. The copyright belongs to the original author. Please consciously delete within 24 hours after downloading. If you use it for commercial purposes, please purchase the original version. If the content posted on this site violates your rights, please contact us to delete it, and we will deal with it in time!

联系我们 Contact us

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏

0
希望看到您的想法,请您发表评论x