因为要做嵌入式开发就不得不安装交叉编译工具链:
Linux下安装软件的方式 :
①在线安装,需要的条件是上网,譬如要安装vim,我们需要输入命令 apt-get install vim。
②自己下载安装包来安装,就是windows中常用的方式,windows当然可以,因为windows版本控制的很好,Linux下有缺陷,因为不知道安装包和系统版本是否符合。兼容性需要考虑。
③高大上的一种方式,拿源代码来经过编译进行安装,这种方式可以进行源代码编译,不合意的还可以修改。这种方式的难度有点大。
安装vim:
插曲:想想我的电脑也没装vim,我先试一下怎么安装vim。就是用在线安装的方式。于是我输入sudo apt-get install vim却出现了:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package vim is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'vim' has no installation candidate
然后我更新源:sudo apt-get update结果还是不行,然后修改了源:sudo gedit /etc/apt/sources.list 然后把里面的删除,然后把下面的内容插进去。
deb http://mirrors.aliyun.com/ubuntu/ trusty main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main multiverse restricted universe
然后再:sudo apt-get update
经过60多个get 和4个Ign后
再输入sudo apt-get install vim
结果还是不行
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:
vim : Depends: vim-common (= 2:7.4.052-1ubuntu3) but 2:7.4.273-2ubuntu4 is to be installed
E: Unable to correct problems, you have held broken packages.
原因可能是安装vim所依赖的vim-common和系统自带的vim-common版本冲突,解决办法就是先把vim-common卸载了人然后再安装vim即可.
sudo apt-get remove vim-common
sudo apt-get install vim
总算成功了!
Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: vim-common vim-runtime Suggested packages: ctags vim-doc vim-scripts The following NEW packages will be installed: vim vim-common vim-runtime 0 upgraded, 3 newly installed, 0 to remove and 74 not upgraded. Need to get 5,860 kB of archives. After this operation, 28.2 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://archive.ubuntu.com/ubuntu/ trusty/main vim-common i386 2:7.4.052-1ubuntu3 [95.2 kB] Get:2 http://archive.ubuntu.com/ubuntu/ trusty/main vim-runtime all 2:7.4.052-1ubuntu3 [4,888 kB] Get:3 http://archive.ubuntu.com/ubuntu/ trusty/main vim i386 2:7.4.052-1ubuntu3 [877 kB] Fetched 5,860 kB in 1min 2s (94.3 kB/s) Selecting previously unselected package vim-common. (Reading database ... 149521 files and directories currently installed.) Preparing to unpack .../vim-common_2%3a7.4.052-1ubuntu3_i386.deb ... Unpacking vim-common (2:7.4.052-1ubuntu3) ... Selecting previously unselected package vim-runtime. Preparing to unpack .../vim-runtime_2%3a7.4.052-1ubuntu3_all.deb ... Adding 'diversion of /usr/share/vim/vim74/doc/help.txt to /usr/share/vim/vim74/doc/help.txt.vim-tiny by vim-runtime' Adding 'diversion of /usr/share/vim/vim74/doc/tags to /usr/share/vim/vim74/doc/tags.vim-tiny by vim-runtime' Unpacking vim-runtime (2:7.4.052-1ubuntu3) ... Selecting previously unselected package vim. Preparing to unpack .../vim_2%3a7.4.052-1ubuntu3_i386.deb ... Unpacking vim (2:7.4.052-1ubuntu3) ... Processing triggers for man-db (2.7.0.2-2) ... Processing triggers for mime-support (3.55ubuntu1) ... Setting up vim-common (2:7.4.052-1ubuntu3) ... Setting up vim-runtime (2:7.4.052-1ubuntu3) ... Processing /usr/share/vim/addons/doc Setting up vim (2:7.4.052-1ubuntu3) ... update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vim (vim) in auto mode update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vimdiff (vimdiff) in auto mode update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rvim (rvim) in auto mode update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rview (rview) in auto mode update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vi (vi) in auto mode update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/view (view) in auto mode update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/ex (ex) in auto mode
好了 这下可以用vim了,直接输入vi也就是vim,不信可以使用 which vi 然后ls -l具体去查看在哪里。好,vim安装到这里算是结束了。
安装交叉编译工具链:
采用第二种方式。
因为第一种在线安装方式不一定有合适的源,第三种水平不够,第二种刚好有别人做好的交叉编译工具链。
交叉编译工具链下载地址:https://yunpan.cn/cq62vfQVeccQX 访问密码 09a7
这里有4款交叉编译工具链。
我们选择交叉编译工具链的原则是:和我们使用的目标平台(给哪款SOC编程)尽量去匹配。譬如我们给s5pv210选用arm-2009q3这个版本,因为三星在给s5pv210开发时就选用的这个版本。我们可以尽量的去减少稀奇古怪的问题。。
好了废话不多说;
①将arm-2009q3.tar.bz2放到/usr/local/arm文件夹下,然后解压 tar jxvf arm-2009q3.tar.bz2
②解压后 得到一个arm-2009q3,这里的bin目录下就是各个交叉编译工具链
注意:如果ubuntu是64位,需要安装对应支持的32位包。命令:
sudo apt-get install ia32-libs
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
Package ia32-libs is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
lib32z1 lib32ncurses5
E: Package 'ia32-libs' has no installation candidate
结果不行我就安装提示中对应的包。
root@joran-X555LD:/usr/local/arm/arm-2009q3/bin# sudo apt-get install lib32z1
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
将会安装下列额外的软件包:
libc6-i386
下列【新】软件包将被安装:
lib32z1 libc6-i386
升级了 0 个软件包,新安装了 2 个软件包,要卸载 0 个软件包,有 181 个软件包未被升级。
需要下载 2,318 kB 的软件包。
解压缩后会消耗掉 10.3 MB 的额外空间。
您希望继续执行吗? [Y/n] y
③现在程序已经安装完毕。所以真正的目录程序在 /usr/local/arm/arm-2009q3/bin下面,现在开始测试,到真正的目录下( /usr/local/arm/arm-2009q3/bin)去执行./arm-none-linux-gnueabi-gcc -v
这样去查看版本号。如果有则表示安装成功。可以在任意目录下创建一个a.c,然后/usr/local/arm/arm-2009q3/bin/arm-none-linux-gnueabi-gcc a.c 这样会得到一个a.out
④
为工具链创建arm-linux-xxx符号链接
创建一个mk-arm-linux-.sh脚本:
ln arm-none-linux-gnueabi-addr2line -s arm-linux-addr2line
ln arm-none-linux-gnueabi-ar -s arm-linux-ar
ln arm-none-linux-gnueabi-as -s arm-linux-as
ln arm-none-linux-gnueabi-c++ -s arm-linux-c++
ln arm-none-linux-gnueabi-c++filt -s arm-linux-c++filt
ln arm-none-linux-gnueabi-cpp -s arm-linux-cpp
ln arm-none-linux-gnueabi-g++ -s arm-linux-g++
ln arm-none-linux-gnueabi-gcc -s arm-linux-gcc
ln arm-none-linux-gnueabi-gcc-4.4.1 -s arm-linux-gcc-4.4.1
ln arm-none-linux-gnueabi-gcov -s arm-linux-gcov
ln arm-none-linux-gnueabi-gdb -s arm-linux-gdb
ln arm-none-linux-gnueabi-gdbtui -s arm-linux-gdbtui
ln arm-none-linux-gnueabi-gprof -s arm-linux-gprof
ln arm-none-linux-gnueabi-ld -s arm-linux-ld
ln arm-none-linux-gnueabi-nm -s arm-linux-nm
ln arm-none-linux-gnueabi-objcopy -s arm-linux-objcopy
ln arm-none-linux-gnueabi-objdump -s arm-linux-objdump
ln arm-none-linux-gnueabi-ranlib -s arm-linux-ranlib
ln arm-none-linux-gnueabi-readelf -s arm-linux-readelf
ln arm-none-linux-gnueabi-size -s arm-linux-size
ln arm-none-linux-gnueabi-sprite -s arm-linux-sprite
ln arm-none-linux-gnueabi-strings -s arm-linux-strings
ln arm-none-linux-gnueabi-strip -s arm-linux-strip
然后执行 source mk-arm-linux-.sh
⑤
导出全部变量: 在~/.bashrc中,添加export PATH=/usr/local/arm/arm-2009q3/bin:$PATH 即可。
#vi ~/.bashrc
export PATH=/usr/local/arm/arm-2009q3/bin:$PATH
最后 source ~/.bashrc
好,大功告成。
如果需要交叉编译工具链可以发邮件到Joran_02@163.com.