centos64位编译32位程序问题

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/kongshuai19900505/article/details/82775688

在centos64位上面编译32位程序的时候遇到编译不过的问题,解决过程如下:

1.编译遇到错误,提示错误如下:

[root@localhost code]# make
In file included from /usr/include/features.h:399:0,
                 from /usr/include/stdint.h:25,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/stdint.h:9,
                 from ../../code/code.h:8,
                 from ../../code/crypto.h:4,
                 from crypto-impl.h:4,
                 from crypto.c:1:
/usr/include/gnu/stubs.h:7:27: fatal error: gnu/stubs-32.h: No such file or directory
 # include <gnu/stubs-32.h>
                           ^
compilation terminated.
make[3]: *** [code_crypto_32_la-crypto.lo] 错误 1
make[2]: *** [all-recursive] 错误 1
make[1]: *** [all-recursive] 错误 1
make: *** [all] 错误 2

这是没有32位库的问题,安装32位libgcc

[root@localhost code]# yum install glibc*.i686

已安装:
  glibc.i686 0:2.17-222.el7                  glibc-devel.i686 0:2.17-222.el7                  glibc-static.i686 0:2.17-222.el7                 

作为依赖被安装:
  nss-softokn-freebl.i686 0:3.36.0-5.el7_5                                                                                                     

作为依赖被升级:
  glibc.x86_64 0:2.17-222.el7                        glibc-common.x86_64 0:2.17-222.el7          glibc-devel.x86_64 0:2.17-222.el7           
  glibc-headers.x86_64 0:2.17-222.el7                nspr.x86_64 0:4.19.0-1.el7_5                nspr-devel.x86_64 0:4.19.0-1.el7_5          
  nss-softokn.x86_64 0:3.36.0-5.el7_5                nss-softokn-devel.x86_64 0:3.36.0-5.el7_5   nss-softokn-freebl.x86_64 0:3.36.0-5.el7_5  
  nss-softokn-freebl-devel.x86_64 0:3.36.0-5.el7_5   nss-util.x86_64 0:3.36.0-1.el7_5            nss-util-devel.x86_64 0:3.36.0-1.el7_5 

2.安装完毕在此make提示“cannot find -lgcc_s”错误

[root@localhost code]#make

/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.8.5/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status
make[3]: *** [libucode-32.la] 错误 1
make[2]: *** [all-recursive] 错误 1
make[1]: *** [all-recursive] 错误 1
make: *** [all] 错误 2

3.上述分析可能是安装32位库没有安装完整,在此安装遇到问题:

[root@localhost code]# yum install libgcc*.i686
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.cn99.com
 * extras: mirrors.tuna.tsinghua.edu.cn
 * updates: mirrors.tuna.tsinghua.edu.cn
正在解决依赖关系
--> 正在检查事务
---> 软件包 libgcc.i686.0.4.8.5-28.el7_5.1 将被 安装
--> 解决依赖关系完成
错误: Multilib version problems found. This often means that the root
      cause is something else and multilib version checking is just
      pointing out that there is a problem. Eg.:
      
        1. You have an upgrade for libgcc which is missing some
           dependency that another package requires. Yum is trying to
           solve this by installing an older version of libgcc of the
           different architecture. If you exclude the bad architecture
           yum will tell you what the root cause is (which package
           requires what). You can try redoing the upgrade with
           --exclude libgcc.otherarch ... this should give you an error
           message showing the root cause of the problem.
      
        2. You have multiple architectures of libgcc installed, but
           yum can only see an upgrade for one of those architectures.
           If you don't want/need both architectures anymore then you
           can remove the one with the missing update and everything
           will work.
      
        3. You have duplicate versions of libgcc installed already.
           You can use "yum check" to get yum show these errors.
      
      ...you can also use --setopt=protected_multilib=false to remove
      this checking, however this is almost never the correct thing to
      do as something else is very likely to go wrong (often causing
      much more problems).
      
      保护多库版本:libgcc-4.8.5-28.el7_5.1.i686 != libgcc-4.8.5-16.el7.x86_64

但是再次安装32位库安装不上,提示版本不对应,这就是因为64位的库和32位的不是一个版本,那么安装32位库之前首先要更新64位库,最起码要保证32位和64位库版本是一致的:

4.更新64位库:

[root@localhost code]# yum install libgcc*

更新完毕:
  libgcc.x86_64 0:4.8.5-28.el7_5.1 

5.更新完毕64位库之后在安装32位没有安装的库:

[root@localhost code]# yum install libgcc*.i686*

已安装:
  libgcc.i686 0:4.8.5-28.el7_5.1 

安装完毕,在此make则可以通过,问题解决

没有更多推荐了,返回首页