在Debian 8中安装 gcc-arm-linux-gnueabi编译debian的 deb安装包

从Debian 的官网中可以发现完全没有 gcc-arm-linux-gnueabi 这个安装包,但是他们在 unstable (sid)中提供了相应的安装包。

以下是提供安装交叉工具链的方法和如何使用交叉编译

  1. 可以通过CrossToolchains — 这篇官方文档来设置安装 相应的交叉编译工具

  2. 安装过软件之后就可以编译相应的软件了,CrossCompiling提供了如何使用交叉编译

但是上面官方提供的方法都会出问题,以下是我在使用的过程中出现的问题,以及修改方法:

root@6d27d5b48e60:/# echo "deb http://emdebian.org/tools/debian/ jessie main" | tee /etc/apt/sources.list.d/embedian-jessie.list
root@6d27d5b48e60:/# curl http://emdebian.org/tools/debian/emdebian-toolchain-archive.key | sudo apt-key add -
root@6d27d5b48e60:/# dpkg --add-architecture armel
root@6d27d5b48e60:/# apt-get update
root@6d27d5b48e60:/# apt-get install -y crossbuild-essential-armel gcc-arm-linux-gnueabi 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 crossbuild-essential-armel : Depends: g++-arm-linux-gnueabi (>= 4.9.1-1) but it is not going to be installed
 gcc-arm-linux-gnueabi : Depends: gcc-4.9-arm-linux-gnueabi (>= 4.9.2-10) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
###########################################################################
可以发现在安装交叉编译工具的出错了,这时我们到刚添加的 http://emdebian.org/tools/debian
上可以发现有相应的软件所以可以简单直接选择安装相应的依赖在解决问题
###########################################################################
root@6d27d5b48e60:/# apt-get install gcc-4.9-arm-linux-gnueabi
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 gcc-4.9-arm-linux-gnueabi : Depends: libgcc-4.9-dev:armel (= 4.9.2-10) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
###########################################################################
这时发现还有依赖直接暗转依赖发现可以安装成功
###########################################################################
root@6d27d5b48e60:/# apt-get install libgcc-4.9-dev:armel
root@6d27d5b48e60:/# apt-get install  libstdc++-4.9-dev:armel

###########################################################################
这时要手动下载相应的 deb 包通过 dpkg 进行安装。
###########################################################################
root@6d27d5b48e60:/#  wget http://emdebian.org/tools/debian/pool/main/c/cross-gcc-4.9-armel/g++-4.9-arm-linux-gnueabi_4.9.2-10_amd64.deb http://emdebian.org/t
ools/debian/pool/main/c/cross-gcc-4.9-armel/gcc-4.9-arm-linux-gnueabi_4.9.2-10_amd64.deb http://emdebian.org/tools/debian/pool/main/c/cross-gcc-4.9-armel/cpp-4.9-arm-linux-gnueabi_4.9
.2-10_amd64.deb http://emdebian.org/tools/debian/pool/main/c/cross-binutils/binutils-arm-linux-gnueabi_2.25-8_amd64.deb

root@6d27d5b48e60:/# dpkg -i  cpp-4.9-arm-linux-gnueabi_4.9.2-10_amd64.deb
root@6d27d5b48e60:/# dpkg -i binutils-arm-linux-gnueabi_2.25-8_amd64.deb 
root@6d27d5b48e60:/# dpkg -i  gcc-4.9-arm-linux-gnueabi_4.9.2-10_amd64.deb
root@6d27d5b48e60:/# dpkg -i  g++-4.9-arm-linux-gnueabi_4.9.2-10_amd64.deb
root@6d27d5b48e60:/usr/bin# ln -s arm-linux-gnueabi-g++-4.9  arm-linux-gnueabi-g++
root@6d27d5b48e60:/usr/bin# ln -s arm-linux-gnueabi-gcc-4.9 arm-linux-gnueabi-gcc 
root@6d27d5b48e60:/usr/bin# ln -s arm-linux-gnueabi-gcov-4.9 arm-linux-gnueabi-gcov

###########################################################################
最后还要解决一个问题就是安装包版本兼容的问题,在安装其他软件是会出现冲突的现象要解决
###########################################################################
root@6d27d5b48e60:/# apt-get install fakeroot
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 fakeroot : Depends: libfakeroot (>= 1.20.2-1) but it is not going to be installed
 g++-4.9-arm-linux-gnueabi : Depends: libstdc++-4.9-dev:armel (= 4.9.2-10) but 4.9.2-10+deb8u1 is to be installed
 gcc-4.9-arm-linux-gnueabi : Depends: libgcc-4.9-dev:armel (= 4.9.2-10) but 4.9.2-10+deb8u1 is to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
root@6d27d5b48e60:/#
###########################################################################
在这个文件中找到相应的软件包把版本比较的信息做相应的修改把 "=" 改为 ">="
###########################################################################
root@6d27d5b48e60:/# vi /var/lib/dpkg/status

交叉编译工具链安装成功后,可以实验一下是否可以使用

$通过 apt 来自动安装编译 armel 的 openssh 依赖的软件包
root@6d27d5b48e60:/# apt-get build-dep -aarmel openssh
root@6d27d5b48e60:/# apt-get source openssh
root@6d27d5b48e60:/#  cd openssh-6.7p1/
root@6d27d5b48e60:/openssh-6.7p1$ CONFIG_SITE=/etc/dpkg-cross/cross-config.armel DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -aarmel

你可能感兴趣的:(Linux)