安裝 STLinux Cross-Compile Enviroment(交叉編譯環境) 至 Ubuntu

    版本為 04:03, 3 Jul 2024

    到這個版本。

    返回到 版本存檔.

    查閱目前版本

    系統環境

    • Ubuntu 8.04.4 (註: 如果使用較新的版本,過程中會發生許多錯誤)
    • STLinux 2.3
    • 網際網路 (安裝後需線上更新所有套件)
       

    安裝前的準備

    使 /bin/sh 使用 bash(註:Ubuntu 預設使用 dash)

    sudo apt-get install bash
    sudo dpkg-reconfigure dash <選 NO>
    

    安裝 rpm

    sudo apt-get install rpm
    sudo apt-get install python-urlgrabber python-rpm python-sqlitecachec python-libxml2
    

    安裝 STLinux (用 ISO 檔)

    下載 STLinux 2.3 ISO
    ftp://ftp.stlinux.com/pub/stlinux/2.3/iso/STLinux-2.3-sh4-03-11-07.iso

    mkdir STLinux
    cd STLinux
    wget ftp://ftp.stlinux.com/pub/stlinux/2.3/iso/STLinux-2.3-sh4-03-11-07.iso 
    sudo rpm -ivh stlinux23-host-STLinux_deps-0.1-5.i386.rpm
    

    掛載 ISO 檔

    sudo mkdir /mnt/iso
    sudo mount -o loop STLinux-2.3-sh4-03-11-07.iso /mnt/iso 
    

    安裝 STLinux

    cd /mnt/iso
    sudo ./install all-sh4-glibc 
    

    如果一切正常,會開始安裝所有套件(約 5XX 個),完成後會出現以下的畫面:

    Complete!
    Warning, could not load sqlite, falling back to pickle

    *************************************************
    *          INSTALLATION COMPLETED               *
    *                                               *
    * Website: http://www.stlinux.com               *
    * Support: https://bugzilla.stlinux.com         *
    *                                               *
    *************************************************

    安裝後的事項

    更新 STLinux 所有套件

    cd /opt/STM/STLinux-2.3/host/bin/
    sudo ./stmyum update
    

    TIPs:

    安裝套件數約 38 個
    更新套件數約 286 個

    建立 Cross-Compile 指令的 PATH

    > vi ~/.profile

    加上這幾行
    # for STLinux Cross-Compile
    export PATH="$PATH:/opt/STM/STLinux-2.3/devkit/sh4/bin/"
    

    驗證一下

    > . ~/.profile
    > sh4-linux-gcc -v

    Using built-in specs.
    Target: sh4-linux
    Configured with: ../configure --target=sh4-linux --prefix=/opt/STM/STLinux-2.3/devkit/sh4 --exec-prefix=/opt/STM/STLinux-2.3/devkit/sh4 --bindir=/opt/STM/STLinux-2.3/devkit/sh4/bin --sbindir=/opt/STM/STLinux-2.3/devkit/sh4/sbin --sysconfdir=/opt/STM/STLinux-2.3/devkit/sh4/etc --datadir=/opt/STM/STLinux-2.3/devkit/sh4/share --includedir=/opt/STM/STLinux-2.3/devkit/sh4/include --libdir=/opt/STM/STLinux-2.3/devkit/sh4/lib --libexecdir=/opt/STM/STLinux-2.3/devkit/sh4/libexec --localstatedir=/opt/STM/STLinux-2.3/devkit/sh4/var --sharedstatedir=/opt/STM/STLinux-2.3/devkit/sh4/share --mandir=/opt/STM/STLinux-2.3/devkit/sh4/man --infodir=/opt/STM/STLinux-2.3/devkit/sh4/info --enable-checking=assert --program-prefix=sh4-linux- --with-local-prefix=/opt/STM/STLinux-2.3/devkit/sh4 --with-sysroot=/opt/STM/STLinux-2.3/devkit/sh4/target --enable-languages=c,c++ --enable-threads=posix --enable-nls --enable-c99 --enable-long-long --with-system-zlib --enable-shared --disable-libgomp --enable-multilib --with-multilib-list=m4,m4-nofpu --enable-symvers=gnu --with-gxx-include-dir=${prefix}/target/usr/include/c++/4.2.4 --enable-__cxa_atexit
    Thread model: posix
    gcc version 4.2.4 (snapshot) (STMicroelectronics/Linux Base 4.2.4-73) 
    

    Cross-Compile 交叉編譯

    主要編譯指令集

    Tool Native Name STLinux
     GNU C Compiler  gcc  sh4-linux-gcc
     GNU C++ Compiler  g++  sh4-linux-g++
     GNU C++ Pre-processor  cpp  sh4-linux-cpp
     GNU Linker  ld  sh4-linux-ld
     GNU Assembler  as  sh4-linux-as
     GNU Librarian  ar  sh4-linux-ar

     

     

    Powered by MindTouch Core