Linux下安裝交叉工具鏈&&安裝vim


因為要做嵌入式開發就不得不安裝交叉編譯工具鏈: 

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.

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM