「我可以使用X64構建ARM的gcc嗎?」
是的,你可以。我已經在blog post of mine中描述了suse linux主機開發系統的這個過程。
============================================== ==================================== 我要複製這裏的步驟:
1.確保有必要的標頭&庫安裝我已經使用YaST的「安裝軟件」功能,安裝下面的包,這將需要完成所有的構建步驟
(只搜索包名,選擇並接受):
- GMP-devel的
- MPFR-devel的
- MPC-devel的
- 的texinfo
- ncurses的devel的
- 的termcap
2.創建一個目錄骨架
cd ~
mkdir arm-none-eabi arm-none-eabi-src
cd arm-none-eabi
mkdir src build
cd ~/arm-none-eabi-src
mkdir src build
3.下載的源碼包,並提取它們
我使用gcc-4.7.1
這裏,當然,同樣的過程將適用於GCC的新版本。
cd ~/arm-none-eabi-src/src
wget ftp://ftp.gnu.org/gnu/gcc/gcc-4.7.1/gcc-4.7.1.tar.bz2
wget ftp://ftp.gnu.org/gnu/binutils/binutils-2.22.tar.bz2
wget ftp://ftp.gnu.org/gnu/gdb/gdb-7.4.tar.bz2
wget ftp://sources.redhat.com/pub/newlib/newlib-1.20.0.tar.gz
tar -xf gcc-4.7.1.tar.bz2
tar -xf binutils-2.22.tar.bz2
tar -xf gdb-7.4.tar.bz2
tar -xf newlib-1.20.0.tar.gz
4.生成binutils的
cd ~/arm-none-eabi-src/build
mkdir binutils-2.22
cd binutils-2.22
../../src/binutils-2.22/configure \
--target=arm-none-eabi \
--prefix=$HOME/arm-none-eabi \
--with-cpu=cortex-m3 \
--with-no-thumb-interwork \
--with-mode=thumb
make all install
export PATH="$PATH:$HOME/arm-none-eabi/bin"
5.構建GCC(第1部分)
cd ~/arm-none-eabi-src/build
mkdir gcc-4.7.1
cd gcc-4.7.1
../../src/gcc-4.7.1/configure --target=arm-none-eabi \
--prefix=$HOME/arm-none-eabi --with-cpu=cortex-m3 \
--with-mode=thumb --disable-multilib \
--with-no-thumb-interwork \
--enable-languages="c,c++" --with-newlib \
--with-headers=../../src/newlib-1.20.0/newlib/libc/include
make all-gcc install-gcc
的--enable-CXX-標誌配置選項可能被附加地用來控制的libstdC++(包含在此步驟)的構建國旗:
--enable-cxx-flags='-fno-exceptions \
-ffunction-sections -fno-omit-frame-pointer'
通常相同的C++應該使用編譯標誌,因爲它們在構建預期的目標代碼時會出現。
6.構建GCC newlib與交叉編譯器(第2部分)
cd ~/arm-none-eabi-src/build
mkdir newlib-1.20.0
cd newlib-1.20.0
../../src/newlib-1.20.0/configure --target=arm-none-eabi \
--prefix=$HOME/arm-none-eabi --disable-multilib \
--disable-newlib-supplied-syscalls
make all install
有關--disable-newlib-supplied-syscalls
選項的說明:
禁用默認newlib系統調用存根實現通常是一個當你打算編譯目標而不使用像操作系統這樣的linux,或者根本沒有操作系統時,這是個好主意。它會讓你在未實現的存根函數上留下鏈接錯誤,你需要爲newlib提供這些函數。 刪除該選項仍然可以使您用自己的實現覆蓋newlib提供的存根。
雖然,當您打算將交叉工具鏈與CMake結合使用時,應該省略此選項。 CMake使用指定的編譯器定義(例如來自toolchain.cmake文件)執行一些基本測試,如果沒有提供默認存根實現,它將會失敗。
7.完成安裝GCC
cd ~/arm-none-eabi-src/build/gcc-4.7.1
make all install
8.生成GDB
cd ~/arm-none-eabi-src/build
mkdir gdb-7.4
cd gdb-7.4
../../src/gdb-7.4/configure --target=arm-none-eabi \
--prefix=$HOME/arm-none-eabi
make all install
UPDATE
同樣的作品相當不錯GCC 4.8.2也。
[this](http://dev-jungle.blogspot.de/2013/09/building-gcc-471-arm-cross-toolchain-on.html)有幫助嗎? – 2014-10-10 18:28:43
除了正常的[交叉編譯器](https://gcc.gnu。org/wiki/Building_Cross_Toolchains_with_gcc)?有很多方法可以構建一個,雖然它可能更容易與幫助工具,如[crosstool ng](http://crosstool-ng.org/) – nos 2014-10-10 18:29:18
@nos的幫助時,有很多方法達到相同的目標,並且沒有集中的文檔來源:這是一個問題;因此我的困惑。我知道crosstool-ng,我想根據自己的需要自己做所有事情。 – user2485710 2014-10-10 18:30:38