Ubuntu22.04.1LTS编译OpenWRT

// 清除 bin 目录
make clean
// 清除 bin 目录 + 清除交叉编译工具及工具链目录
make dirclean
// 清除所有相关的东西,包括下载的软件包,配置文件,feed内容等
make distclean

1. 安装编译需要的rpm包

yum install -y epel-release

yum install -y subversion binutils bzip2 gcc gcc-c++ gawk gettext flex ncurses-devel zlib-devel make patch unzip perl-ExtUtils-MakeMaker  glibc glibc-devel glibc-static sed intltool sharutils bison wget git-core openssl-devel xz zlib-static quilt ncurses-lib sdcc 

**** 最后的zilb-static 一定要安装,要不然make defconfig检查通不过 ***

会报如下错误:

==========

Build dependency: Please install a static zlib. (Missing libz.a or zlib.h)

Prerequisite check failed. Use FORCE=1 to override.
make: *** [staging_dir/host/.prereq-build] Error 1

==========

2. 新建一个普通用户

官方建议用普通用户编译源码。这里我们就新建一个。我就用onlyellow表示

useradd michael

2、编译环境前奏

Build dependency: Please install GNU make v4.1 or later.
Build dependency: Please install the GNU C Compiler (gcc) 6 or later
Build dependency: Please install the GNU C++ Compiler (g++) 6 or later
Build dependency: Please install Python >= 3.6
Build dependency: Please install Python >= 3.6
Build dependency: Please install the Python3 distutils module

2.1、make环境

1、下载make安装包
wget http://ftp.gnu.org/gnu/make/make-4.1.tar.gz
2、解压make安装包
tar -zxvf make-4.1.tar.gz
3、编译/安装
cd make-4.1
./configure
make
make install
4、链接
ln -s -f /usr/local/bin/make /usr/bin/make
5、查看make版本
make -v

2.1、gcc

2.3 python

1、下载python的新版本,下载地址为:
https://www.python.org/ftp/python/
wget https://www.python.org/ftp/python/3.9.9/Python-3.9.9.tgz

2、解压安装包
将安装包放置到/tmp/目录,进入/tmp/,然后解压。(个人习惯)
tar -zxf Python-3.9.9.tgz

3、配置安装包:
cd Python-3.9.9
sudo ./configure

4、编译并安装python。默认会安装到/usr/local/bin 
sudo make
sudo make install

5、把新python加入python列表
sudo update-alternatives --install /usr/bin/python python /usr/local/bin/python3.9 9
6、查看当前列表,我自己只看到3.9.9这一个版本。
update-alternatives --list python

7、配置优先级
如若查看列表不是一个版本,就需要配置优先级。我只一个版本,故没有这一步。
update-alternatives --config python
输入后,键入新的python的序号,回车即可。

8、查看python版本号。
python --version
显示python3.9.9,即说明升级成功。

sudo apt-get install python3-distutils

3. 切换到普通用户,下载OpenWRT源码

https://git.openwrt.org/
在这里插入图片描述

git clone git://git.openwrt.org/openwrt/openwrt.git

5. 用screen

万一ssh断了不会影响编译。建议使用

6. feed增加包

cd openwrt

cp feeds.conf.default feeds.conf
./scripts/feeds update -a
./scripts/feeds install -a

7. 检查环境

make defconfig

8. 选择目标环境

make menuconfig

在这里插入图片描述

9. 编译

直接编译
make
带输出debug信息编译
make V=99
带输出debug信息并且并行编译。N为你想使用的cpu核数。如果不带参数默认是1。
make -j N V=99

bash

sudo apt-get install libncurses5-dev  zlib1g-dev gawk flex patch git-core g++ subversion 

猜你喜欢

转载自blog.csdn.net/Michael_lcf/article/details/131187516