开源路由器-OpenWRT/梅林

前言

近段时间,有朋友咨询路由器刷梅林系统,定制上网加速的方案。我研究了一下,整理了一些常规资料共享出来,方便与新入手的朋友学习。

开源路由器

开源路由器有多个版本

OpenWRT、LEDE、华硕梅林,老毛子,潘多拉、LEAN等,它们之间的关系,如图:
在这里插入图片描述
网上收集到的

  • LEDE是OpenWRT的一个分支,现2018年1月,已宣布合并成OpenWRT了。
  • 梅林和老毛子基本是性能好一些,功能也比较全,硬件转发能力的固件支持都不错,梅林主要是BCM方案的路由用的(BCM一般都是温度高一些),华硕老毛子基本是MTK的方案用的,梅林可以双拨,华硕老毛子不能双拨
  • LEDE和潘多拉一样都是基于OPENWRT的,潘多拉可以多拨,其他还行。
  • LEDE可以多拨,硬件转发能力的固件支持只有软NAT,其余也还行。
  • 其实他们在一般使用上最大的区别就是多拨和硬件转发能力,多拨就不说了,硬件转发能力和CPU能力强的最明显的体现就是负载较多时,CPU使用率较低,有个例子就是迅雷远程和KP广告过滤,硬件转发能力和CPU强的话,这俩应用比较好用,还有就是从路由器存储到终端存储的文件读写速率会高很多
  • 老毛子是mtk华硕,梅林是博通华硕,mtk还有个华硕固件。潘多拉是linter开发的固件。
  • 潘多拉是带闭源无线驱动的修改版openwrt。
  • 老毛子是指俄罗斯人开发的基于华硕源代码的Padavan固件。
  • A大固件:专指abccba94发布的固件。他发布有多种固件,例如老毛子,梅林固件等。不过最出名的固件是基于官方固件的修改版本(官改版)。

个人观点:

  • 发烧友级别用梅林,因为支持梅林的基本都是华硕的路由器,且价格都高于500元。
  • 低成本的用OpenWRT,支持的设备很多,9百多种设备型号,TP-Link的支持得很全,百元左右的路由器大部分都支持。

OpenWRT

官网OpenWrt ,截图:
在这里插入图片描述
OpenWrt支持设备列表,很多,几百个,截图如下:
在这里插入图片描述
百度百科OpenWRT,截图:
在这里插入图片描述

LEDE

(Linux Embedded Development Environment) Linux嵌入式开发环境项目,是OpenWRT的一个分支项目,继承原来OpenWRT的开发目标。2018年1月 LEDE 和 OpenWRT 正式宣布合并,合并后的项目使用OpenWrt的名字。百度百科LEDE,部分截图:
在这里插入图片描述

华硕梅林

华硕梅林官网

华硕梅林:https://www.asuswrt-merlin.net/source
在这里插入图片描述

华硕梅林文档

文档:https://github.com/RMerl/asuswrt-merlin/wiki ,如图:
在这里插入图片描述

开发工具链

开发工具链:https://github.com/RMerl/am-toolchains ,如图:
在这里插入图片描述

梅林论坛

https://koolshare.cn/forum.php?gid=95
在这里插入图片描述
Asuswrt-merlin基本操作截图如下:
在这里插入图片描述

刷机梅林

https://koolshare.cn/thread-127878-1-1.html
在这里插入图片描述

小宝梅林插件

https://github.com/koolshare/armsoft
在这里插入图片描述

梅林插件开发

梅林改版固件软件中心的开发教程
在这里插入图片描述

/home/yzf/env/toolchain/bin/../lib/gcc/aarch64-openwrt-linux-gnu/12.3.0/../../../../aarch64-openwrt-linux-gnu/bin/ld: warning: libc.so, needed by ../lib/libxml2.so, not found (try using -rpath or -rpath-link) /home/yzf/env/toolchain/bin/../lib/gcc/aarch64-openwrt-linux-gnu/12.3.0/../../../../aarch64-openwrt-linux-gnu/bin/ld: ../lib/libsqlite3.so: undefined reference to `sinh' /home/yzf/env/toolchain/bin/../lib/gcc/aarch64-openwrt-linux-gnu/12.3.0/../../../../aarch64-openwrt-linux-gnu/bin/ld: ../lib/libsqlite3.so: undefined reference to `log2' /home/yzf/env/toolchain/bin/../lib/gcc/aarch64-openwrt-linux-gnu/12.3.0/../../../../aarch64-openwrt-linux-gnu/bin/ld: ../lib/libsqlite3.so: undefined reference to `atan2' /home/yzf/env/toolchain/bin/../lib/gcc/aarch64-openwrt-linux-gnu/12.3.0/../../../../aarch64-openwrt-linux-gnu/bin/ld: ../lib/libsqlite3.so: undefined reference to `tanh' /home/yzf/env/toolchain/bin/../lib/gcc/aarch64-openwrt-linux-gnu/12.3.0/../../../../aarch64-openwrt-linux-gnu/bin/ld: ../lib/libsqlite3.so: undefined reference to `atanh' /home/yzf/env/toolchain/bin/../lib/gcc/aarch64-openwrt-linux-gnu/12.3.0/../../../../aarch64-openwrt-linux-gnu/bin/ld: ../lib/libsqlite3.so: undefined reference to `cosh' /home/yzf/env/toolchain/bin/../lib/gcc/aarch64-openwrt-linux-gnu/12.3.0/../../../../aarch64-openwrt-linux-gnu/bin/ld: ../lib/libxml2.so: undefined reference to `fmod' /home/yzf/env/toolchain/bin/../lib/gcc/aarch64-openwrt-linux-gnu/12.3.0/../../../../aarch64-openwrt-linux-gnu/bin/ld: ../lib/libsqlite3.so: undefined reference to `acosh' /home/yzf/env/toolchain/bin/../lib/gcc/aarch64-openwrt-linux-gnu/12.3.0/../../../../aarch64-openwrt-linux-gnu/bin/ld: ../lib/libsqlite3.so: undefined reference to `acos' /home/yzf/env/toolchain/bin/../lib/gcc/aarch64-openwrt-linux-gnu/12.3.0/../../../../aarch64-openwrt-linux-gnu/bin/ld: ../lib/libsqlite3.so: undefined reference to `sin' /home/yzf/env/toolchain/bin/../lib/gcc/aarch64-openwrt-linux-gnu/12.3.0/../../../../aarch64-openwrt-linux-gnu/bin/ld: ../lib/libsqlite3.so: undefined reference to `atan' /home/yzf/env/toolchain/bin/../lib/gcc/aarch64-openwrt-linux-gnu/12.3.0/../../../../aarch64-openwrt-linux-gnu/bin/ld: ../lib/libsqlite3.so: undefined reference to `asin' /home/yzf/env/toolchain/bin/../lib/gcc/aarch64-openwrt-linux-gnu/12.3.0/../../../../aarch64-openwrt-linux-gnu/bin/ld: ../lib/libsqlite3.so: undefined reference to `exp' /home/yzf/env/toolchain/bin/../lib/gcc/aarch64-openwrt-linux-gnu/12.3.0/../../../../aarch64-openwrt-linux-gnu/bin/ld: ../lib/libsqlite3.so: undefined reference to `trunc' /home/yzf/env/toolchain/bin/../lib/gcc/aarch64-openwrt-linux-gnu/12.3.0/../../../../aarch64-openwrt-linux-gnu/bin/ld: ../lib/libsqlite3.so: undefined reference to `tan' /home/yzf/env/toolchain/bin/../lib/gcc/aarch64-openwrt-linux-gnu/12.3.0/../../../../aarch64-openwrt-linux-gnu/bin/ld: ../lib/libsqlite3.so: undefined reference to `cos' /home/yzf/env/toolchain/bin/../lib/gcc/aarch64-openwrt-linux-gnu/12.3.0/../../../../aarch64-openwrt-linux-gnu/bin/ld: ../lib/libsqlite3.so: undefined reference to `log' /home/yzf/env/toolchain/bin/../lib/gcc/aarch64-openwrt-linux-gnu/12.3.0/../../../../aarch64-openwrt-linux-gnu/bin/ld: ../lib/libxml2.so: undefined reference to `pow' /home/yzf/env/toolchain/bin/../lib/gcc/aarch64-openwrt-linux-gnu/12.3.0/../../../../aarch64-openwrt-linux-gnu/bin/ld: ../lib/libxml2.so: undefined reference to `log10' /home/yzf/env/toolchain/bin/../lib/gcc/aarch64-openwrt-linux-gnu/12.3.0/../../../../aarch64-openwrt-linux-gnu/bin/ld: ../lib/libsqlite3.so: undefined reference to `sqrt' /home/yzf/env/toolchain/bin/../lib/gcc/aarch64-openwrt-linux-gnu/12.3.0/../../../../aarch64-openwrt-linux-gnu/bin/ld: ../lib/libsqlite3.so: undefined reference to `asinh' collect2: error: ld returned 1 exit status
最新发布
11-14
你遇到的链接错误是典型的 **动态库依赖缺失** 问题,特别是在交叉编译 OpenWrt 或嵌入式 Linux 系统时非常常见。我们来详细分析并解决这个问题。 --- ### 🔍 错误信息解析 你的错误分为两类: #### 1. `libc.so, needed by ../lib/libxml2.so, not found` ```bash warning: libc.so, needed by ../lib/libxml2.so, not found ``` 这表示链接器找不到 C 标准库(`libc.so`),通常是 `libc.so.6` 的别名或软链接。说明你的交叉编译工具链中缺少对标准 C 库的正确路径配置。 #### 2. 大量 `undefined reference to 'sin', 'cos', 'log', 'pow'...` ```bash undefined reference to `sin`, `cos`, `log`, `exp`, `sqrt`, `fmod`, `atan2`, ... ``` 这些函数都属于 **数学库 `libm.so`**,它们虽然在头文件 `<math.h>` 中声明了,但实现是在 `-lm` 这个库中提供的。所以你需要显式地链接数学库。 此外,像 `libxml2.so` 和 `libsqlite3.so` 是你自己提供的预编译库(位于 `../lib/`),它们在构建时可能依赖了 `libm` 和 `libc`,但在当前链接环境中找不到这些底层依赖。 --- ## ✅ 解决方案 ### ✔️ 步骤一:确保包含正确的系统库路径(sysroot) 你需要告诉链接器去哪里找目标平台的系统库(如 `libc.so`, `libm.so`)。通常这个目录在你的 toolchain 的 `sysroot` 下。 例如: ``` /home/yzf/env/toolchain/aarch64-openwrt-linux-gnu/sysroot/ ``` 然后使用 `-L` 指定该路径下的 `lib` 目录: ```bash -L/home/yzf/env/toolchain/aarch64-openwrt-linux-gnu/sysroot/lib ``` > 📌 提示:你可以运行以下命令查看是否存在这些库: ```bash ls /home/yzf/env/toolchain/aarch64-openwrt-linux-gnu/sysroot/lib/libc.so* ls /home/yzf/env/toolchain/aarch64-openwrt-linux-gnu/sysroot/lib/libm.so* ``` 如果没有,请检查你的 toolchain 是否完整,或者是否需要从 OpenWrt SDK 安装完整的 sysroot。 --- ### ✔️ 步骤二:显式链接数学库 `-lm` 即使你在代码里包含了 `<math.h>`,你也必须在链接时加上 `-lm` 来链接数学库。 ```bash -lm ``` 放在链接命令的最后面(遵循链接顺序原则)。 --- ### ✔️ 步骤三:确保 `libxml2.so` 和 `libsqlite3.so` 所依赖的库也能被找到 如果你自己编译过这两个库,确认它们也是用相同的 toolchain 编译,并且其依赖项(如 `libm`)已经静态链接或可在目标系统上找到。 如果这些 `.so` 文件是在不同环境下编译的,可能会导致 ABI 不兼容或依赖丢失。 --- ### ✅ 修改后的链接命令示例 假设你正在编译一个叫 `myapp` 的程序,原来可能是这样: ```bash aarch64-openwrt-linux-gnu-gcc main.c -o myapp ../lib/libxml2.so ../lib/libsqlite3.so ``` 现在应该改为: ```bash aarch64-openwrt-linux-gnu-gcc \ main.c \ -I../include \ -L../lib \ -L/home/yzf/env/toolchain/aarch64-openwrt-linux-gnu/sysroot/lib \ -lxml2 -lsqlite3 \ -lm -lc \ -o myapp ``` 或者更稳妥一点(避免重复指定 `.so`): ```bash aarch64-openwrt-linux-gnu-gcc \ main.c \ -I../include \ -L../lib \ -L/home/yzf/env/toolchain/aarch64-openwrt-linux-gnu/sysroot/lib \ -L/home/yzf/env/toolchain/aarch64-openwrt-linux-gnu/lib/gcc/aarch64-openwrt-linux-gnu/12.3.0 \ -lxml2 -lsqlite3 \ -lm -lc -lgcc \ -o myapp ``` 📌 注意: - `-lm`: 链接数学库(解决 sin, cos, log 等) - `-lc`: 显式链接 C 库(有时可省略,但加上保险) - `-lgcc`: 如果有底层 GCC 内建函数调用,也需要这个 - 使用 `-lxml2` 而不是直接写 `libxml2.so` 更规范(前提是 `.so` 在库路径中) --- ### ✅ 可选:使用 `-rpath-link` 解决警告 针对 `libc.so not found` 的 warning,可以加 `-rpath-link` 帮助链接器解析依赖: ```bash -Wl,-rpath-link,/home/yzf/env/toolchain/aarch64-openwrt-linux-gnu/sysroot/lib ``` 完整加入编译命令: ```bash aarch64-openwrt-linux-gnu-gcc \ main.c \ -I../include \ -L../lib \ -L/home/yzf/env/toolchain/aarch64-openwrt-linux-gnu/sysroot/lib \ -Wl,-rpath-link,/home/yzf/env/toolchain/aarch64-openwrt-linux-gnu/sysroot/lib \ -lxml2 -lsqlite3 \ -lm -lc \ -o myapp ``` --- ## 🛠️ 补充建议 1. **不要手动拷贝 `.so` 到项目中而不管理依赖** - 推荐使用 `pkg-config` 来自动获取编译和链接参数。 - 示例(如果你有正确的 `.pc` 文件): ```bash pkg-config --cflags libxml-2.0 pkg-config --libs libxml-2.0 ``` 2. **检查你的预编译库依赖关系** ```bash aarch64-openwrt-linux-gnu-readelf -d ../lib/libsqlite3.so | grep NEEDED ``` 输出会显示它需要哪些共享库(如 `libm.so.6`, `libc.so.6`),然后你要确保这些都能被链接器找到。 3. **终极调试手段:打印详细链接过程** ```bash aarch64-openwrt-linux-gnu-gcc -v ... # 查看实际调用的 ld 命令 ``` --- ### 总结 | 问题 | 原因 | 解决方法 | |------|------|----------| | `libc.so not found` | 缺少 sysroot 中的 libc 路径 | 添加 `-L<sysroot>/lib` | | `undefined reference to sin/log/pow` | 未链接数学库 | 加上 `-lm` | | 动态库找不到依赖 | 缺少 rpath 或路径不对 | 使用 `-Wl,-rpath-link,...` | ---
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值