OpenWRT编译指南-By luochen570

发布时间 2023-04-21 14:07:32作者: 阿风小子

今年年初我开始玩的 openwrt,刚刚开始只是想 找一个可以高度自定义的路由

市场上的系统很多 梅林 Padavan (老毛子)  OpenWRT等等

当时看上了openwrt主要还是插件多(日常需要正常访问google查资料github复制粘贴)

在网上找了很多固件都不是很尽如人意,便想着自己编译固件中间豪赌哟艰辛(编译了好几个小时神秘报错*n)

特此出了一篇教程(铁废废bi bi lai lai)

编译需要linux环境和一定的 linux的基础

装ubuntu虚拟机不会的可以去看这位大大的视频

https://www.bilibili.com/video/BV1aW411C7NR?spm_id_from=333.337.search-card.all.click&;vd_source=b8176d4eb791c03a4f6cfe6dc33e58d8

#编译正式开始(垃圾废物天天搞不好这些)

#建议使用ubuntu或者debian进行编译

#arch也可以但是依赖不一样具体 可以参考这位博主#https://www.dazhuanlan.com/apologizen/topics/1649643(如有侵权请私信删除)

#更新软件列表

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-pip qemu-utils \

rsync scons squashfs-tools subversion swig texinfo uglifyjs upx-ucl unzip vim wget xmlto xxd zlib1g-dev

 

 

#本次拉取lean大源码

#拉取lean-Openwrt 源码

#https://github.com/coolsnowwolf/lede直接下载

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

git clone https://github.com/coolsnowwolf/lede #拉取lean源码git pull #更新同步源码

 

#其他源码地址

#官方源:

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

#Lean 源:

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

#Lienol 源:

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

#immortalwrt 源:

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

 

 

#进入编译文件夹(只要位置对了就可以)

cd ~/lede

 

 

#添加部分插件源-可以选择添加feeds源或者直接git拉源代码(可选建议选上这一步)

#添加 feeds源

#一键命令

sed -i '$a src-git kenzo https://github.com/kenzok8/openwrt-packages' feeds.conf.default

sed -i '$a src-git small https://github.com/kenzok8/small' feeds.conf.default

 


 

#编辑文件 feeds.conf.default 文件在源码根目录中,使用自己喜欢的文本编辑器编辑(vim nano)添加一下几行

sudo nano feeds.conf.default

#通常这两个就够了

src-git kenzo https://github.com/kenzok8/openwrt-packages

src-git small https://github.com/kenzok8/small 

 

#src-git helloworld https://github.com/fw876/helloworld

#src-git passwall https://github.com/xiaorouji/openwrt-passwall

#src-git lienol https://github.com/Lienol/openwrt-package

 


 

#也可以选择拉取插件源码

#git拉取Hello World源码

cd lede/package/lean/ 

#git lua-maxminddb 依赖 

git clone https://github.com/jerrykuku/lua-maxminddb.git

git clone https://github.com/jerrykuku/luci-App-vssr.git  

 

 

#更新feeds文件

./scripts/feeds update -a

./scripts/feeds install -a

为了保险建议打两遍和图2一样就没问题了

 

 


#制作配置文件

#插件翻译Luci - Applications

#https://www.right.com.cn/forum/thread-344825-1-1.html

#选择好后选 Save保存 /退回主页面双击ESC后敲回车

#保存时不用重命名我是个哈皮

make menuconfig

#小提示:编译丰富插件时,建议修改下面两项默认大小,留足插件空间。( x86/64 )!!!

#Target Images ---> (16) Kernel partition size (in MB)                        

#默认是 (16) 建议修改 (256)

#Target Images ---> (160) Root filesystem partition size (in MB)         

#默认是 (160) 建议修改 (512)

 


 

#下载 dll库,编译固件 (-j 后面是线程数,取决于cpu线程数)

#切记全局**(因为服务器在国外)

make download -j8

#开始编译文件,多线程会更快哦(-j 后面是线程数,第一次编译推荐用单线程)

make V=s -j1

(这两个我就不放图了 懒)

 

#编译完成后输出路径:bin/targets

 

 

#二次编译:

cd lede

git pull

./scripts/feeds update -a 

./scripts/feeds install -a

make defconfig

make download -j8

make V=s -j$(nproc)

 

 

#如果需要重新配置:

rm -rf ./tmp && rm -rf .config #清理缓存和配置文件

make menuconfig

make V=s -j$(nproc)

 

 

想用GitHub 在线编译

参考下面链接

https://p3terx.com/archives/build-openwrt-with-github-actions.html

 

本文借鉴这位博主的博客在此表示感谢

#编译openwrt基础教程

https://kmeer.cn/7.html