web-dev-qa-db-ja.com

ARM向けのクロスコンパイル方法

ARMプロセッサのクロスコンパイル用にGCCを設定するにはどうすればよいですか?ホストはx86_64(AMD64-Ubuntu 12.04)にあり、ターゲットはARM(Raspberry PiとPandaboard-それぞれに対して個別のコンパイルを行います)になりますか?

41
haziz

gcc-arm-linux-gnueabiおよびbinutils-arm-linux-gnueabiパッケージをインストールし、コンパイルにgccの代わりにarm-linux-gnueabi-gccを使用します。

ターゲットシステムで使用しているlinuxおよびbinutilsのフレーバーに注意する必要があります。最新のものはハードフロートです。この場合、次のようにします。

Sudo apt-get install gcc-arm-linux-gnueabihf

これにより、binutilsを含む完全なクロスコンパイル環境が実現します。

43
Maratyszcza

ディスクイメージプロバイダーは、互換性のあるクロスコンパイラも提供する必要があります

これが唯一の信頼できる方法です。

特にRPIの場合、提供されているクロスコンパイラは次の場所にあります。 https://github.com/raspberrypi/tools で説明されているとおりに使用できます。 https://raspberrypi.stackexchange .com/questions/64273/installing-raspberry-pi-cross-compiler/83215#83215

git clone https://github.com/raspberrypi/tools
export PATH="$(pwd)/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin:${PATH}"
printf '#include <stdio.h>\nint main() { puts("hello world"); }\n' > hello_world.c
printf '#include <iostream>\nint main() { std::cout << "hello world" << std::endl; }\n' > hello_world.cpp
arm-linux-gnueabihf-gcc -std=c99 -o hello_world_c hello_world.c
arm-linux-gnueabihf-g++ -std=c++11 -o hello_world_cpp hello_world.cpp

誤ってクロスコンパイラを所有している場合、次のことが発生する可能性があります。

私のお気に入りの選択肢は、Buildrootで独自のイメージを構築することです: https://stackoverflow.com/questions/47557262/how-to-download-the-torvalds-linux-kernel-master-recompile-it-and- boot-it-wi/49349237#49349237 これにより、すべてがソースからビルドされ、すべての互換性が確保されます。