注意
- 不要用 root 用户进行编译
- 国内用户编译前最好准备好梯子
- 默认登陆IP 192.168.1.1 密码 password
编译命令
首先装好 Linux 系统,推荐 Debian 11 或 Ubuntu LTS
安装编译依赖
bash 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下载源代码,更新 feeds 并选择配置并编译openclash和ssrplus+(helloword)
`bash ## 拉取ledegit clone https://github.com/coolsnowwolf/lede # 下载OpenClash wget https://github.com/vernesong/OpenClash/archive/master.zip # 解压 unzip master.zip # 复制OpenClash软件包到Lede cp -r OpenClash-master/luci-app-openclash lede/package cd lede
# 编译ssrplus sed -i "/helloworld/d" "feeds.conf.default" echo "src-git helloworld https://github.com/fw876/helloworld.git" >> "feeds.conf.default" ./scripts/feeds update -a ./scripts/feeds install -a make menuconfig`下载 dl 库,编译固件 (-j 后面是线程数,第一次编译推荐用单线程)
bash make download -j8 make V=s -j1
本套代码保证肯定可以编译成功。里面包括了 R23 所有源代码,包括 IPK 的。
你可以自由使用,但源码编译二次发布请注明我的 GitHub 仓库链接。谢谢合作!
二次编译:
bash
cd lede
git pull
./scripts/feeds update -a
./scripts/feeds install -a
make defconfig
make download -j8
make V=s -j$(nproc)
如果需要重新配置:
bash
rm -rf ./tmp && rm -rf .config
make menuconfig
make V=s -j$(nproc)
编译完成后输出路径:bin/targets
如果你使用 WSL/WSL2 进行编译
由于 WSL 的 PATH 中包含带有空格的 Windows 路径,有可能会导致编译失败,请在 make 前面加上:
bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
由于默认情况下,装载到 WSL 发行版的 NTFS 格式的驱动器将不区分大小写,因此大概率在 WSL/WSL2 的编译检查中会返回以下错误:
txt
Build dependency: OpenWrt can only be built on a case-sensitive filesystem
一个比较简洁的解决方法是,在 git clone 前先创建 Repository 目录,并为其启用大小写敏感:
`powershell
以管理员身份打开终端
PS > fsutil.exe file setCaseSensitiveInfo <yourlocallede_path> enable
将本项目 git clone 到开启了大小写敏感的目录 <yourlocallede_path> 中
PS > git clone git@github.com:coolsnowwolf/lede.git <yourlocallede_path>
`
对已经
git clone完成的项目目录执行fsutil.exe命令无法生效,大小写敏感只对新增的文件变更有效。
macOS 原生系统进行编译
在 AppStore 中安装 Xcode
安装 Homebrew:
bash /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"使用 Homebrew 安装工具链、依赖与基础软件包:
bash brew unlink awk brew install coreutils diffutils findutils gawk gnu-getopt gnu-tar grep make ncurses pkg-config wget quilt xz brew install gcc@11然后输入以下命令,添加到系统环境变量中:
bash echo 'export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"' >> ~/.bashrc echo 'export PATH="/usr/local/opt/findutils/libexec/gnubin:$PATH"' >> ~/.bashrc echo 'export PATH="/usr/local/opt/gnu-getopt/bin:$PATH"' >> ~/.bashrc echo 'export PATH="/usr/local/opt/gnu-tar/libexec/gnubin:$PATH"' >> ~/.bashrc echo 'export PATH="/usr/local/opt/grep/libexec/gnubin:$PATH"' >> ~/.bashrc echo 'export PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"' >> ~/.bashrc echo 'export PATH="/usr/local/opt/make/libexec/gnubin:$PATH"' >> ~/.bashrc重新加载一下 shell 启动文件
source ~/.bashrc,然后输入bash进入 bash shell,就可以和 Linux 一样正常编译了
评论
发表评论