前言:
什么是BuildRoot?
Buildroot is a tool that simplifies and automates the process of building a complete Linux system for an embedded system, using cross-compilation.
In order to achieve this, Buildroot is able to generate a cross-compilation toolchain, a root filesystem, a Linux kernel image and a bootloader for your target. Buildroot can be used for any combination of these options, independently (you can for example use an existing cross-compilation toolchain, and build only your root filesystem with Buildroot).
Buildroot is useful mainly for people working with embedded systems. Embedded systems often use processors that are not the regular x86 processors everyone is used to having in his PC. They can be PowerPC processors, MIPS processors, ARM processors, etc.
Buildroot supports numerous processors and their variants; it also comes with default configurations for several boards available off-the-shelf. Besides this, a number of third-party projects are based on, or develop their BSP [1] or SDK [2] on top of Buildroot.
安装交叉编译依赖 :
sudo apt-get install libncurses5-dev patch
下载BuildRoot交叉编译工具:
git clone https://github.com/buildroot/buildroot.git
cd buildroot
或者直接wget下载:
wget https://buildroot.org/downloads/snapshots/buildroot-snapshot.tar.bz2
tar -xvf buildroot-snapshot.tar.bz2
cd buildroot
配置编译选项:
make clean
make menuconfig
-选择架构:
-配置Toolchain
使用uname -a指令查看目标设备的内核版本
配置好之后选择下面的Save选项进行保存。
正式开始编译:
注意编译的过程中需要保持良好的网络连接,因为需要下载一些依赖库。
make -j$(nproc)
最后生成出来mips架构的gcc和g++:
将编译出来的进行软连接到系统的/usr/bin当中:
ln -s /home/kxd/buildroot/output/host/bin/mipsel-linux-* /usr/bin/
用Cpp写一个helloworld进行测试:
编译命令行:
mipsel-linux-g++ -o ./hello_mips ./hello.cpp -static
file一下看看文件类型
上传到刷过openwrt的mips架构的路由器上
成功。