千家信息网

编译OpenWRT过程问题该怎么解决

发表于:2026-11-01 作者:千家信息网编辑
千家信息网最后更新 2026年11月01日,编译OpenWRT过程问题该怎么解决,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。本人的操作系统是CentOS 6.4(好久都没有换过了
千家信息网最后更新 2026年11月01日编译OpenWRT过程问题该怎么解决

编译OpenWRT过程问题该怎么解决,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。

本人的操作系统是CentOS 6.4(好久都没有换过了)。本人按照网上牛人们的指点也开始下载编译OpenWRT。

如下为网上的资料:


sudo apt-get update (更新)
安装编译需要的组件:
sudo apt-get install gcc
sudo apt-get install g++
sudo apt-get install binutils
sudo apt-get install patch
sudo apt-get install bzip2
sudo apt-get install flex
sudo apt-get install bison
sudo apt-get install make
sudo apt-get install autoconf
sudo apt-get install gettext
sudo apt-get install texinfo
sudo apt-get install unzip
sudo apt-get install sharutils
sudo apt-get install subversion
sudo apt-get install libncurses5-dev
sudo apt-get install ncurses-term
sudo apt-get install zlib1g-dev
sudo apt-get install gawk
sudo apt-get install asciidoc
sudo apt-get install libz-dev

编译环境搭建完成
mkdir openwrt 创建一个openwrt文件夹
cd openwrt 进入openwrt文件夹
svn co svn://svn.openwrt.org/openwrt/branches/backfire 下载官网的源码
./scripts/feeds update -a 更新软件包
./scripts/feeds install -a 安装软件包
make menuconfig 进入定制界面(里面可以选择芯片的型号,集成的组件等等,根据实际情况选择)
defconfig
make V=99 (开始编译)
剩下的就是等待了,第一次编译需要的时间相对比较长,这个跟你的电脑配置和网速有关。


由于原作者是用的Ubuntu作为开发环境,所以在安装上面的那些依赖工具包时都是用 apt-get 来安排的,在CentOS里采用 yum。其实都一样,只要知道依赖哪些包就行了。

本人checkout 的OpenWRT源码库路径为 : svn://svn.openwrt.org/openwrt/trunk

其它的都按上面的步骤做。

如下是我遇到的几个问题:

./scripts/feeds update -a失败

报:

$ ./scripts/feeds update -aUpdating feed 'packages' from 'https://github.com/openwrt/packages.git' ...Cloning into './feeds/packages'...fatal: Unable to find remote helper for 'https'failed.

可能是git仓库路径不对,将https替换成git就可以了。

用 grep 命令搜

$ grep 'https://github.com' feeds/* -Rfeeds/packages.tmp/location:https://github.com/openwrt/packages.git

那就把这个地方改一下啰。

再试一下。结果还是老样子,我想了一下,这个 feeds/packages.tmp/location 很可能是临时文。改它不会有效果的。

好像 feeds.conf.default 文件里也找到了。

$ grep 'https://github.com' feeds.conf.default -Rsrc-git packages https://github.com/openwrt/packages.gitsrc-git luci https://github.com/openwrt/luci.gitsrc-git routing https://github.com/openwrt-routing/packages.gitsrc-git telephony https://github.com/openwrt/telephony.gitsrc-git management https://github.com/openwrt-management/packages.gitsrc-git targets https://github.com/openwrt/targets.git

将里面所有https替换成git。

再试一下,OK了。

后记:其实还有更根本的解决方法,详见后期的博文《git 错误:Unable to find remote helper for 'https'》

gconvert.c libiconv

我在第一次编译OpenWRT时,出现如下错误提示:

gconvert.c:66:2: error: #error GNU libiconv not in use but included iconv.h is from libiconv

我在网上找解决方案,结果一致地都是说,重新 ./configure 一下:

./configure --enable-iconv=no --with-libiconv=gnumake

可问题的关键是:OpenWRT的trunk路径下没见有个 configure 呀!

后来,经过仔细推敲,发现是在编glib时没通过。

$ find -name "gconvert.c"./build_dir/host/pkg-config-0.28/glib/glib/gconvert.c

那我就直接进到 ./build_dir/host/pkg-config-0.28/glib/ 路径下,发现该路径下有 configure 文件。

那我说直接在该路径下编译 glib

$ cd build_dir/host/pkg-config-0.28/glib/./configure --enable-iconv=no --with-libiconv=gnumake

这样,glib 就顺利通过了编译。

再回到 OpenWRT的trunk路径下,继续 make.

libubox安装错误

报错:

mkdir -p /home/hevake_lcj/Workspace/OpenWRT/trunk/dlecho "Checking out files from the git repository..."; mkdir -p /home/hevake_lcj/Workspace/OpenWRT/trunk/tmp/dl && cd /home/hevake_lcj/Workspace/OpenWRT/trunk/tmp/dl && rm -rf libubox-2015-03-22 && [ \! -d libubox-2015-03-22 ] && git clone http://git.openwrt.org/project/libubox.git libubox-2015-03-22 --recursive && (cd libubox-2015-03-22 && git checkout b8d9b382e39823850331edc2a92379173daf1be3 && git submodule update) && echo "Packing checkout..." && rm -rf libubox-2015-03-22/.git &&     tar czf /home/hevake_lcj/Workspace/OpenWRT/trunk/tmp/dl/libubox-2015-03-22-b8d9b382e39823850331edc2a92379173daf1be3.tar.gz libubox-2015-03-22 && mv /home/hevake_lcj/Workspace/OpenWRT/trunk/tmp/dl/libubox-2015-03-22-b8d9b382e39823850331edc2a92379173daf1be3.tar.gz /home/hevake_lcj/Workspace/OpenWRT/trunk/dl/ && rm -rf libubox-2015-03-22; Checking out files from the git repository...Cloning into 'libubox-2015-03-22'...fatal: Unable to find remote helper for 'http'make[3]: *** [/home/hevake_lcj/Workspace/OpenWRT/trunk/dl/libubox-2015-03-22-b8d9b382e39823850331edc2a92379173daf1be3.tar.gz] Error 128

从第二行看出,是用git clone工程:

git clone http://git.openwrt.org/project/libubox.git

整个第三行是将clone下来的源码打包tar.gz包。

于是,我访问了一下:http://git.openwrt.org/project/libubox 果然出现 404页面。看来还真没有?

我再访问了一下:http://git.openwrt.org/ 结果,发现列表里有这个工程:


进入链接 project/libubox.git:

我自己亲自 git clone 一下。

$ cd dl$ mkdir tmp$ cd tmp$ git clone http://git.openwrt.org/project/libubox.git libuboxCloning into 'libubox'...fatal: Unable to find remote helper for 'http'

我在网上找了"fatal: Unable to find remote helper for 'http'"的解决方法。得知将 "http:">

于是,我再次 git clone

$ git clone git://git.openwrt.org/project/libubox.git

结果成功clone了。

然后,手动完成编译命令过程:

mkdir -p /home/hevake_lcj/Workspace/OpenWRT/trunk/tmp/dlcd /home/hevake_lcj/Workspace/OpenWRT/trunk/tmp/dlrm -rf libubox-2015-03-22git clone git://git.openwrt.org/project/libubox.git libubox-2015-03-22 echo "Packing checkout..." rm -rf libubox-2015-03-22/.gittar czf libubox-2015-03-22-b8d9b382e39823850331edc2a92379173daf1be3.tar.gz libubox-2015-03-22mv libubox-2015-03-22-b8d9b382e39823850331edc2a92379173daf1be3.tar.gz ../../dl/rm -rf libubox-2015-03-22;

然后,回到OpenWRT的trunk路径下继续 make.

fatal: Unable to find remote helper for 'http'

编译报错:

make[3]: Entering directory `/home/hevake_lcj/Workspace/OpenWRT/trunk/package/network/config/netifd'mkdir -p /home/hevake_lcj/Workspace/OpenWRT/trunk/dlecho "Checking out files from the git repository..."; mkdir -p /home/hevake_lcj/Workspace/OpenWRT/trunk/tmp/dl \ && cd /home/hevake_lcj/Workspace/OpenWRT/trunk/tmp/dl \ && rm -rf netifd-2015-03-31 \ && [ \! -d netifd-2015-03-31 ] \ && git clone http://git.openwrt.org/project/netifd.git netifd-2015-03-31 --recursive \ && (cd netifd-2015-03-31 \ && git checkout 3a0f953722698eab6f3f623a1d6ec5a1b7102b77 \ && git submodule update) && echo "Packing checkout..." \ && rm -rf netifd-2015-03-31/.git \ && tar czf /home/hevake_lcj/Workspace/OpenWRT/trunk/tmp/dl/netifd-2015-03-31-3a0f953722698eab6f3f623a1d6ec5a1b7102b77.tar.gz netifd-2015-03-31 \ && mv /home/hevake_lcj/Workspace/OpenWRT/trunk/tmp/dl/netifd-2015-03-31-3a0f953722698eab6f3f623a1d6ec5a1b7102b77.tar.gz /home/hevake_lcj/Workspace/OpenWRT/trunk/dl/ \ && rm -rf netifd-2015-03-31;

找到 package/network/config/netifd/Makefile,打开


将第8行的"http:"替换成"git:",然后再回到OpenWRT目录再make.


注:后来我还会反复遇到这个问题。火了!一条命令全部换掉!

$ grep -E "http:.*\.git" `find -name Makefile | xargs` | \  awk -F: '!/.svn/{print $1}' | uniq | xargs \  sed -i 's/http\(:.*\.git\)/git\1/g'

在trunk目录下,找出Makefile中有"http:xxxxx.git"的文件,并将所有的"http:xxxxx.git"替换成"git:xxxxx.git"

$ grep -E "https:.*\.git" `find -name Makefile | xargs` | \  awk -F: '!/.svn/{print $1}' | uniq | xargs \  sed -i 's/https\(:.*\)\.git/git\1\.git/g'

把 https 也替换成 git

opkg下载失败

Checking out files from the git repository...Cloning into 'opkg-9c97d5ecd795709c8584e972bfdf3aee3a5b846d'...fatal: Could not read from remote repository.

这时往上看一下,看make到哪儿了

make[3]: Entering directory `/home/hevake_lcj/Workspace/OpenWRT/trunk/package/system/opkg'

原来是 opkg 在 git clone 时可能是路径的问题,失败了。

我尝试打开 opkg 路径下的 Makefile,将

PKG_SOURCE_URL:=http://git.yoctoproject.org/git/opkg

改成:

PKG_SOURCE_URL:=git://git.yoctoproject.org/git/opkg

结果还是没有生效。

我手动搜opkg,找到官网: http://git.yoctoproject.org/cgit/cgit.cgi/opkg/ 打开,看到网页最下面有:

于是,我改 trunk/package/system/opkg/Makefile 文件,把 PKG_SOURCE_URL改成:

PKG_SOURCE_URL:=git://git.yoctoproject.org/opkg

继续 make,通过了!

linux-firmware clone失败

fatal: Unable to look up git.kernel.org (port 9418) (Temporary failure in name resolution)

我到 git.kernel.org 网站找到了 linux-firmware 的仓库 https://git.kernel.org/cgit/linux/kernel/git/balbi/linux-firmware.git/

看到最下面的 git 路径说明:


这与 Makefile 里指定的不统一。于是将Makefile里的git路径改过来


再 make

我现在都总结出经验来了。

凡是git clone失败的,如果是http头的问题,将http替换成git再试。

如果还是不行,就要检查一下git的路径是不是对的。简单的方法就是到 git 路径的根节点上去找出源码仓库,并得到其真实有效的git路径。

并将Makefile中的改过来就OK了。

linux-firmware fatal: reference is not a tree 问题

make[3]: Entering directory `/home/hevake_lcj/Workspace/OpenWRT/trunk/package/kernel/mac80211'mkdir -p /home/hevake_lcj/Workspace/OpenWRT/trunk/dlecho "Checking out files from the git repository..."; mkdir -p /home/hevake_lcj/Workspace/OpenWRT/trunk/tmp/dl \  && cd /home/hevake_lcj/Workspace/OpenWRT/trunk/tmp/dl \  && rm -rf linux-firmware-f404336ba808cbd57547196e13367079a23b822c \  && [ \! -d linux-firmware-f404336ba808cbd57547196e13367079a23b822c ] \  && git clone git://git.kernel.org/pub/scm/linux/kernel/git/balbi/linux-firmware.git linux-firmware-f404336ba808cbd57547196e13367079a23b822c --recursive \  && (cd linux-firmware-f404336ba808cbd57547196e13367079a23b822c \    && git checkout f404336ba808cbd57547196e13367079a23b822c \    && git submodule update) \  && echo "Packing checkout..." \  && rm -rf linux-firmware-f404336ba808cbd57547196e13367079a23b822c/.git \  && tar cjf /home/hevake_lcj/Workspace/OpenWRT/trunk/tmp/dl/linux-firmware-2015-03-20-f404336ba808cbd57547196e13367079a23b822c.tar.bz2 linux-firmware-f404336ba808cbd57547196e13367079a23b822c \  && mv /home/hevake_lcj/Workspace/OpenWRT/trunk/tmp/dl/linux-firmware-2015-03-20-f404336ba808cbd57547196e13367079a23b822c.tar.bz2 /home/hevake_lcj/Workspace/OpenWRT/trunk/dl/ \  && rm -rf linux-firmware-f404336ba808cbd57547196e13367079a23b822c; Checking out files from the git repository...Cloning into 'linux-firmware-f404336ba808cbd57547196e13367079a23b822c'...remote: Counting objects: 2344, done.remote: Compressing objects: 100% (1164/1164), done.remote: Total 2344 (delta 1182), reused 2272 (delta 1145)Receiving objects: 100% (2344/2344), 42.07 MiB | 26 KiB/s, done.Resolving deltas: 100% (1182/1182), done.fatal: reference is not a tree: f404336ba808cbd57547196e13367079a23b822cmake[3]: *** [/home/hevake_lcj/Workspace/OpenWRT/trunk/dl/linux-firmware-2015-03-20-f404336ba808cbd57547196e13367079a23b822c.tar.bz2] Error 128make[3]: Leaving directory `/home/hevake_lcj/Workspace/OpenWRT/trunk/package/kernel/mac80211'

fatal: reference is not a tree: f404....22c,意思好像是说git工程里没有 f404...22c 这么版本。那么我得检查一下这个版本号对不对。

在trunk/tmp/dl路径下下载的linux-firmware还没有删掉,我们进入该目录。并用git log查看一下提交日志,得到:

commit b8ac7c7e27dcd13fa3c843aaf62457e9c57ea4dbAuthor: Rasesh Mody Date:   Tue Sep 10 16:10:54 2013 -0700    linux-firmware: Add Brocade FC/FCOE Adapter firmware files        This patch adds firmware files for Brocade HBA and CNA drivers(BFA and BNA).        Signed-off-by: Rasesh Mody     Signed-off-by: Ben Hutchings commit 8ff6cc3a5e1d9452ae8fb993532afc1f3ab3a71fMerge: 1461bed e7c85b2Author: Ben Hutchings Date:   Mon Sep 30 04:50:51 2013 +0100    Merge branch 'moxa' of https://github.com/lunn/linux-firmwarecommit 1461bed1300097efeba59c82ffa30c90cc7e3ae5Author: Alex Deucher Date:   Mon Aug 26 10:45:33 2013 -0400    radeon: add ucode for KAVERI GPUs        Add new ucode files and update the WHENCE entry.        Signed-off-by: Alex Deucher     Signed-off-by: Ben Hutchings commit 66f87a226160b545ac02f3844ea601cbe10a5da2Author: Alex Deucher Date:   Mon Aug 26 10:42:44 2013 -0400    radeon: add smc ucode for BONAIRE

在这里面,没有搜到 f404336ba808cbd57547196e13367079a23b822c 这个版本号

那,我就将其改成最新的版本号吧 b8ac7c7e27dcd13fa3c843aaf62457e9c57ea4db,但愿没有问题。


同时,将 trunk/tmp/dl/下的原下载目录改名(避免反复下载)、

$ cd tmp/dl$ mv linux-firmware-f404336ba808cbd57547196e13367079a23b822c/ linux-firmware-b8ac7c7e27dcd13fa3c843aaf62457e9c57ea4db

好!我们再 make 一下。

看完上述内容,你们掌握编译OpenWRT过程问题该怎么解决的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注行业资讯频道,感谢各位的阅读!

路径 编译 问题 文件 方法 结果 源码 版本 目录 过程 仓库 命令 工程 还是 错误 面的 不对 内容 就是 手动 数据库的安全要保护哪些东西 数据库安全各自的含义是什么 生产安全数据库录入 数据库的安全性及管理 数据库安全策略包含哪些 海淀数据库安全审计系统 建立农村房屋安全信息数据库 易用的数据库客户端支持安全管理 连接数据库失败ssl安全错误 数据库的锁怎样保障安全 互联网科技 互联网金融科技 南京欣网互联网络科技 国智互联网科技 深圳互联网科技公司 北京禾田雨橡互联网科技 哈尔滨秒房互联网科技有限公司 蓝色互联网科技 老年人脱离互联网科技的作文 须眉科技是互联网公司吗 央行互联网金融科技公司 千方科技属于互联网企业吗 民营互联网公司国防科技 互联网科技公司营业执照怎么办理 工业互联网山东科技大学 国大互联网教育科技有限公司薪资 上海钢联属于互联网科技股吗 浙南科技城互联网大厦招聘 数字科技和互联网金融哪个好 颐高云石互联网科技 广州紫鲸互联网科技 中正互联网科技招聘 武汉健翔互联网络科技有限公司 呼和浩特新华互联网科技学院 世界互联网领先科技成果获奖 无锡工业互联网科技有限公司 互联网科技平台产品运营 互联网科技创新方面的资料 互联网企业和网络科技有限公司 科技互联网企业在行动
0