在centos64位上面編譯32位程式的時候遇到編譯不過的問題,解決過程如下:
1.編譯遇到錯誤,提示錯誤如下:
[[email protected] 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
[[email protected] 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”錯誤
[[email protected] 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位庫沒有安裝完整,在此安裝遇到問題:
[[email protected] 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位庫:
[[email protected] code]# yum install libgcc*
更新完畢:
libgcc.x86_64 0:4.8.5-28.el7_5.1
5.更新完畢64位庫之後在安裝32位沒有安裝的庫:
[[email protected] code]# yum install libgcc*.i686*
已安裝:
libgcc.i686 0:4.8.5-28.el7_5.1
安裝完畢,在此make則可以通過,問題解決