openwrt编译环境的搭建

  OpenWRT是一个高度模块化、高度自动化的嵌入式Linux系统,拥有强大的网络组件和扩展性,它是一个从零开始编写的、功能齐全的、容易修改的路由器操作系统。
  OpenWRT的官方网站是:https://openwrt.org/
  在github上有两个源码使用的比较多
  一个是lede,地址为:https://github.com/coolsnowwolf/lede
  另一个为OpenWrt的官方源码:https://github.com/lede-project

一、搭建环境

  在虚拟机里面使用Ubuntu,将Ubuntu 的源设置为阿里源。
  下载lede的源码方法为:

git clone https://github.com/coolsnowwolf/lede

  下载OpenWrt的官方源码方法为:

git clone https://github.com/openwrt/openwrt.git

二、编译lede源码

2.1、安装编译依赖

sudo apt update -y
sudo apt full-upgrade -y
sudo apt install -y ack antlr3 asciidoc autoconf automake autopoint binutils bison build-essential \
bzip2 ccache cmake cpio curl device-tree-compiler fastjar flex gawk gettext gcc-multilib g++-multilib \
git gperf haveged help2man intltool libc6-dev-i386 libelf-dev libglib2.0-dev libgmp3-dev libltdl-dev \
libmpc-dev libmpfr-dev libncurses5-dev libncursesw5-dev libreadline-dev libssl-dev libtool lrzsz \
mkisofs msmtp nano ninja-build p7zip p7zip-full patch pkgconf python2.7 python3 python3-pyelftools \
libpython3-dev qemu-utils rsync scons squashfs-tools subversion swig texinfo uglifyjs upx-ucl unzip \
vim wget xmlto xxd zlib1g-dev python3-setuptools

2.2、更新 feeds 并选择配置

cd lede
./scripts/feeds update -a
./scripts/feeds install -a
make menuconfig

2.3、下载 dl 库,编译固件 (-j 后面是线程数,第一次编译推荐用单线程)

make download -j8
make V=s -j1

2.4、二次编译

cd lede
git pull
./scripts/feeds update -a
./scripts/feeds install -a
make defconfig
make download -j8
make V=s -j$(nproc)

2.5、如果需要重新配置:

rm -rf ./tmp && rm -rf .config
make menuconfig
make V=s -j$(nproc)

  编译完成后输出路径:bin/targets
  注意:不要用 root 用户进行编译

三、编译OpenWrt的官方源码

  使用上述方法编译OpenWrt的官方源码也可以成功。

猜你喜欢

转载自blog.csdn.net/xxxx123041/article/details/132481271