arm-linux-gcc編譯時出現的一些小插曲-----64位系統需要32位的庫
最近由於工作的需要,重新弄起arm-linux-gcc編譯。離上一次弄這些有整整10年了。
我是在一臺64位的機器上實機安裝的 centos7 發行版,系統和交叉編譯器的安裝過程自是沒話說,問題出在使用arm-linux-gcc編譯
arm程式時,
$ arm-linux-gcc main.c /opt/FriendlyARM/toolschain/4.4.3/libexec/gcc/arm-none-linux-gnueabi/4.4.3/cc1: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
提示找不到庫檔案 libstdc++.so.6 , 在確定系統裡確實沒有該檔案,且環境變數正常的情況下,決定安裝之
sudo yum install libstdc++.so.6 , 不料出現以下情況:
已載入外掛:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * epel: mirrors.aliyun.com * extras: centos.cs.nctu.edu.tw * nux-dextop: li.nux.ro * updates: mirrors.aliyun.com 正在解決依賴關係 --> 正在檢查事務 ---> 軟體包 libstdc++.i686.0.4.8.5-28.el7_5.1 將被 安裝 --> 正在處理依賴關係 libgcc_s.so.1(GLIBC_2.0),它被軟體包 libstdc++-4.8.5-28.el7_5.1.i686 需要 --> 正在處理依賴關係 libgcc_s.so.1(GCC_4.2.0),它被軟體包 libstdc++-4.8.5-28.el7_5.1.i686 需要 --> 正在處理依賴關係 libgcc_s.so.1(GCC_3.3),它被軟體包 libstdc++-4.8.5-28.el7_5.1.i686 需要 --> 正在處理依賴關係 libgcc_s.so.1(GCC_3.0),它被軟體包 libstdc++-4.8.5-28.el7_5.1.i686 需要 --> 正在處理依賴關係 libgcc_s.so.1,它被軟體包 libstdc++-4.8.5-28.el7_5.1.i686 需要 --> 正在檢查事務 ---> 軟體包 libgcc.x86_64.0.4.8.5-28.el7 將被 升級 ---> 軟體包 libgcc.i686.0.4.8.5-28.el7_5.1 將被 安裝 ---> 軟體包 libgcc.x86_64.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 libstdc++ which is missing some dependency that another package requires. Yum is trying to solve this by installing an older version of libstdc++ 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 libstdc++.otherarch ... this should give you an error message showing the root cause of the problem. 2. You have multiple architectures of libstdc++ 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 libstdc++ 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). 保護多庫版本:libstdc++-4.8.5-28.el7_5.1.i686 != libstdc++-4.8.5-28.el7.x86_64
大意是:在安裝32位的庫的同時也在更新64位的庫,所以出現了多庫版本問題。
在網上搜同樣的問題,得到的資料提示要分開安裝和更新。
好吧,先更新64位的庫:
sudo yum update libstdc++-4.8.5-28.el7.x86_64
已載入外掛:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * epel: mirrors.aliyun.com * extras: centos.communilink.net * nux-dextop: li.nux.ro * updates: mirrors.aliyun.com 正在解決依賴關係 --> 正在檢查事務 ---> 軟體包 libstdc++.x86_64.0.4.8.5-28.el7 將被 升級 --> 正在處理依賴關係 libstdc++ = 4.8.5-28.el7,它被軟體包 gcc-c++-4.8.5-28.el7.x86_64 需要 --> 正在處理依賴關係 libstdc++(x86-64) = 4.8.5-28.el7,它被軟體包 libstdc++-devel-4.8.5-28.el7.x86_64 需要 ---> 軟體包 libstdc++.x86_64.0.4.8.5-28.el7_5.1 將被 更新 --> 正在檢查事務 ---> 軟體包 gcc-c++.x86_64.0.4.8.5-28.el7 將被 升級 ---> 軟體包 gcc-c++.x86_64.0.4.8.5-28.el7_5.1 將被 更新 --> 正在處理依賴關係 gcc = 4.8.5-28.el7_5.1,它被軟體包 gcc-c++-4.8.5-28.el7_5.1.x86_64 需要 ---> 軟體包 libstdc++-devel.x86_64.0.4.8.5-28.el7 將被 升級 ---> 軟體包 libstdc++-devel.x86_64.0.4.8.5-28.el7_5.1 將被 更新 --> 正在檢查事務 ---> 軟體包 gcc.x86_64.0.4.8.5-28.el7 將被 升級 --> 正在處理依賴關係 gcc = 4.8.5-28.el7,它被軟體包 libquadmath-devel-4.8.5-28.el7.x86_64 需要 --> 正在處理依賴關係 gcc = 4.8.5-28.el7,它被軟體包 gcc-gfortran-4.8.5-28.el7.x86_64 需要 ---> 軟體包 gcc.x86_64.0.4.8.5-28.el7_5.1 將被 更新 --> 正在處理依賴關係 libgomp = 4.8.5-28.el7_5.1,它被軟體包 gcc-4.8.5-28.el7_5.1.x86_64 需要 --> 正在處理依賴關係 cpp = 4.8.5-28.el7_5.1,它被軟體包 gcc-4.8.5-28.el7_5.1.x86_64 需要 --> 正在處理依賴關係 libgcc >= 4.8.5-28.el7_5.1,它被軟體包 gcc-4.8.5-28.el7_5.1.x86_64 需要 --> 正在檢查事務 ---> 軟體包 cpp.x86_64.0.4.8.5-28.el7 將被 升級 ---> 軟體包 cpp.x86_64.0.4.8.5-28.el7_5.1 將被 更新 ---> 軟體包 gcc-gfortran.x86_64.0.4.8.5-28.el7 將被 升級 ---> 軟體包 gcc-gfortran.x86_64.0.4.8.5-28.el7_5.1 將被 更新 --> 正在處理依賴關係 libquadmath = 4.8.5-28.el7_5.1,它被軟體包 gcc-gfortran-4.8.5-28.el7_5.1.x86_64 需要 --> 正在處理依賴關係 libgfortran = 4.8.5-28.el7_5.1,它被軟體包 gcc-gfortran-4.8.5-28.el7_5.1.x86_64 需要 ---> 軟體包 libgcc.x86_64.0.4.8.5-28.el7 將被 升級 ---> 軟體包 libgcc.x86_64.0.4.8.5-28.el7_5.1 將被 更新 ---> 軟體包 libgomp.x86_64.0.4.8.5-28.el7 將被 升級 ---> 軟體包 libgomp.x86_64.0.4.8.5-28.el7_5.1 將被 更新 ---> 軟體包 libquadmath-devel.x86_64.0.4.8.5-28.el7 將被 升級 ---> 軟體包 libquadmath-devel.x86_64.0.4.8.5-28.el7_5.1 將被 更新 --> 正在檢查事務 ---> 軟體包 libgfortran.x86_64.0.4.8.5-28.el7 將被 升級 ---> 軟體包 libgfortran.x86_64.0.4.8.5-28.el7_5.1 將被 更新 ---> 軟體包 libquadmath.x86_64.0.4.8.5-28.el7 將被 升級 ---> 軟體包 libquadmath.x86_64.0.4.8.5-28.el7_5.1 將被 更新 --> 解決依賴關係完成
依賴關係解決
================================================================================ Package 架構 版本 源 大小 ================================================================================ 正在更新: libstdc++ x86_64 4.8.5-28.el7_5.1 updates 303 k 為依賴而更新: cpp x86_64 4.8.5-28.el7_5.1 updates 5.9 M gcc x86_64 4.8.5-28.el7_5.1 updates 16 M gcc-c++ x86_64 4.8.5-28.el7_5.1 updates 7.2 M gcc-gfortran x86_64 4.8.5-28.el7_5.1 updates 6.7 M libgcc x86_64 4.8.5-28.el7_5.1 updates 101 k libgfortran x86_64 4.8.5-28.el7_5.1 updates 299 k libgomp x86_64 4.8.5-28.el7_5.1 updates 156 k libquadmath x86_64 4.8.5-28.el7_5.1 updates 188 k libquadmath-devel x86_64 4.8.5-28.el7_5.1 updates 51 k libstdc++-devel x86_64 4.8.5-28.el7_5.1 updates 1.5 M
事務概要 ================================================================================ 升級 1 軟體包 (+10 依賴軟體包)
總計:39 M Is this ok [y/d/N]: y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction 正在更新 : libquadmath-4.8.5-28.el7_5.1.x86_64 1/22 正在更新 : libgcc-4.8.5-28.el7_5.1.x86_64 2/22 正在更新 : libstdc++-4.8.5-28.el7_5.1.x86_64 3/22 正在更新 : libstdc++-devel-4.8.5-28.el7_5.1.x86_64 4/22 正在更新 : libgfortran-4.8.5-28.el7_5.1.x86_64 5/22 正在更新 : cpp-4.8.5-28.el7_5.1.x86_64 6/22 正在更新 : libgomp-4.8.5-28.el7_5.1.x86_64 7/22 正在更新 : gcc-4.8.5-28.el7_5.1.x86_64 8/22 正在更新 : libquadmath-devel-4.8.5-28.el7_5.1.x86_64 9/22 正在更新 : gcc-gfortran-4.8.5-28.el7_5.1.x86_64 10/22 正在更新 : gcc-c++-4.8.5-28.el7_5.1.x86_64 11/22 清理 : gcc-c++-4.8.5-28.el7.x86_64 12/22 清理 : gcc-gfortran-4.8.5-28.el7.x86_64 13/22 清理 : libquadmath-devel-4.8.5-28.el7.x86_64 14/22 清理 : libstdc++-devel-4.8.5-28.el7.x86_64 15/22 清理 : gcc-4.8.5-28.el7.x86_64 16/22 清理 : libgfortran-4.8.5-28.el7.x86_64 17/22 清理 : libstdc++-4.8.5-28.el7.x86_64 18/22 清理 : libgcc-4.8.5-28.el7.x86_64 19/22 清理 : libquadmath-4.8.5-28.el7.x86_64 20/22 清理 : cpp-4.8.5-28.el7.x86_64 21/22 清理 : libgomp-4.8.5-28.el7.x86_64 22/22 驗證中 : libgomp-4.8.5-28.el7_5.1.x86_64 1/22 驗證中 : libstdc++-devel-4.8.5-28.el7_5.1.x86_64 2/22 驗證中 : gcc-4.8.5-28.el7_5.1.x86_64 3/22 驗證中 : libgfortran-4.8.5-28.el7_5.1.x86_64 4/22 驗證中 : gcc-gfortran-4.8.5-28.el7_5.1.x86_64 5/22 驗證中 : libgcc-4.8.5-28.el7_5.1.x86_64 6/22 驗證中 : cpp-4.8.5-28.el7_5.1.x86_64 7/22 驗證中 : libquadmath-4.8.5-28.el7_5.1.x86_64 8/22 驗證中 : gcc-c++-4.8.5-28.el7_5.1.x86_64 9/22 驗證中 : libquadmath-devel-4.8.5-28.el7_5.1.x86_64 10/22 驗證中 : libstdc++-4.8.5-28.el7_5.1.x86_64 11/22 驗證中 : gcc-gfortran-4.8.5-28.el7.x86_64 12/22 驗證中 : libgomp-4.8.5-28.el7.x86_64 13/22 驗證中 : libstdc++-4.8.5-28.el7.x86_64 14/22 驗證中 : libstdc++-devel-4.8.5-28.el7.x86_64 15/22 驗證中 : libgcc-4.8.5-28.el7.x86_64 16/22 驗證中 : gcc-4.8.5-28.el7.x86_64 17/22 驗證中 : libgfortran-4.8.5-28.el7.x86_64 18/22 驗證中 : libquadmath-4.8.5-28.el7.x86_64 19/22 驗證中 : libquadmath-devel-4.8.5-28.el7.x86_64 20/22 驗證中 : cpp-4.8.5-28.el7.x86_64 21/22 驗證中 : gcc-c++-4.8.5-28.el7.x86_64 22/22
更新完畢: libstdc++.x86_64 0:4.8.5-28.el7_5.1
作為依賴被升級: cpp.x86_64 0:4.8.5-28.el7_5.1 gcc.x86_64 0:4.8.5-28.el7_5.1 gcc-c++.x86_64 0:4.8.5-28.el7_5.1 gcc-gfortran.x86_64 0:4.8.5-28.el7_5.1 libgcc.x86_64 0:4.8.5-28.el7_5.1 libgfortran.x86_64 0:4.8.5-28.el7_5.1 libgomp.x86_64 0:4.8.5-28.el7_5.1 libquadmath.x86_64 0:4.8.5-28.el7_5.1 libquadmath-devel.x86_64 0:4.8.5-28.el7_5.1 libstdc++-devel.x86_64 0:4.8.5-28.el7_5.1
完畢!
OK , 然後安裝32位的庫:
sudo yum install libstdc++.i686
已載入外掛:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * epel: mirrors.aliyun.com * extras: mirrors.zju.edu.cn * nux-dextop: li.nux.ro * updates: mirrors.aliyun.com 正在解決依賴關係 --> 正在檢查事務 ---> 軟體包 libstdc++.i686.0.4.8.5-28.el7_5.1 將被 安裝 --> 正在處理依賴關係 libgcc_s.so.1(GLIBC_2.0),它被軟體包 libstdc++-4.8.5-28.el7_5.1.i686 需要 --> 正在處理依賴關係 libgcc_s.so.1(GCC_4.2.0),它被軟體包 libstdc++-4.8.5-28.el7_5.1.i686 需要 --> 正在處理依賴關係 libgcc_s.so.1(GCC_3.3),它被軟體包 libstdc++-4.8.5-28.el7_5.1.i686 需要 --> 正在處理依賴關係 libgcc_s.so.1(GCC_3.0),它被軟體包 libstdc++-4.8.5-28.el7_5.1.i686 需要 --> 正在處理依賴關係 libgcc_s.so.1,它被軟體包 libstdc++-4.8.5-28.el7_5.1.i686 需要 --> 正在檢查事務 ---> 軟體包 libgcc.i686.0.4.8.5-28.el7_5.1 將被 安裝 --> 解決依賴關係完成
依賴關係解決
================================================================================ Package 架構 版本 源 大小 ================================================================================ 正在安裝: libstdc++ i686 4.8.5-28.el7_5.1 updates 317 k 為依賴而安裝: libgcc i686 4.8.5-28.el7_5.1 updates 108 k
事務概要 ================================================================================ 安裝 1 軟體包 (+1 依賴軟體包)
總下載量:425 k 安裝大小:1.2 M Is this ok [y/d/N]: y Downloading packages: (1/2): libstdc++-4.8.5-28.el7_5.1.i686.rpm | 317 kB 00:00 (2/2): libgcc-4.8.5-28.el7_5.1.i686.rpm | 108 kB 00:00 -------------------------------------------------------------------------------- 總計 652 kB/s | 425 kB 00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction 正在安裝 : libgcc-4.8.5-28.el7_5.1.i686 1/2 正在安裝 : libstdc++-4.8.5-28.el7_5.1.i686 2/2 驗證中 : libgcc-4.8.5-28.el7_5.1.i686 1/2 驗證中 : libstdc++-4.8.5-28.el7_5.1.i686 2/2
已安裝: libstdc++.i686 0:4.8.5-28.el7_5.1
作為依賴被安裝: libgcc.i686 0:4.8.5-28.el7_5.1
完畢!
試著編譯:
arm-linux-gcc main.c /opt/FriendlyARM/toolschain/4.4.3/lib/gcc/arm-none-linux-gnueabi/4.4.3/../../../../arm-none-linux-gnueabi/bin/as: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory
看來還缺zlib庫,安裝之:
sudo yum install zlib.i686 已載入外掛:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * epel: mirrors.aliyun.com * extras: centos.cs.nctu.edu.tw * nux-dextop: mirror.li.nux.ro * updates: mirrors.aliyun.com 正在解決依賴關係 --> 正在檢查事務 ---> 軟體包 zlib.i686.0.1.2.7-17.el7 將被 安裝 --> 解決依賴關係完成
依賴關係解決
================================================================================ Package 架構 版本 源 大小 ================================================================================ 正在安裝: zlib i686 1.2.7-17.el7 base 91 k
事務概要 ================================================================================ 安裝 1 軟體包
總下載量:91 k 安裝大小:180 k Is this ok [y/d/N]: y Downloading packages: zlib-1.2.7-17.el7.i686.rpm | 91 kB 00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction 正在安裝 : zlib-1.2.7-17.el7.i686 1/1 驗證中 : zlib-1.2.7-17.el7.i686 1/1
已安裝: zlib.i686 0:1.2.7-17.el7
完畢!
再編譯
arm-linux-gcc main.c
檢視 ls a.out init.S link.lds main.c Makefile
解決。
最後: 上面的更新和安裝的順序不能顛倒,否則還是出現多庫版本問題。