1、 在编译之前我们先要搭建环境,ubuntu下OpenWrt编译环娓搠础拔境需要安装很多组件:sudoapt-g髫潋啜缅etinstallgccg++binutilspatchbzip2flexbisonmakeautocnfgettexttexinfounzipsharutilssubversionlibncurses5-devncurses-termzlib1g-devsubversiongit-corgawasciidolibz-dev如果你怕有些没安装成功, 也可以一个个安装:sudoapt-getinstallgcc (已安装)sudoapt-getinstallg++(已安装)sudoapt-getinstallbinutils(已安装)sudoapt-getinstallpatch(已安装)sudoapt-getinstallbzip2(已安装)sudoapt-getinstallflex(需安装)sudoapt-getinstallbison(需安装)sudoapt-getinstallmake(已安装)sudoapt-getinstallautoconf(需安装)sudoapt-getinstallgettext(已安装)sudoapt-getinstalltexinfo(需安装)sudoapt-getinstallunzip(已安装)sudoapt-getinstallsharutils(已安装)sudoapt-getinstallsubversion(需安装)sudoapt-getinstalllibncurses5-dev(需安装)sudoapt-getinstallncurses-term(已安装)sudoapt-getinstallzlib1g-dev(已安装)sudoapt-getinstallsubversion(已安装)sudoapt-getinstallgit-core(需安装)sudoapt-getinstallgawk(已安装)sudoapt-getinstallasciidoc(需安装)sudoapt-getinstalllibz-dev当然安装之前最好先更新下组件包:sudoapt-getupdate这里小编选择逐个安装
2、 经过小编逐个安装,发现大部分在ubuntu16.04系统中就已经安装好了,只需再安装以下几款:sudoapt-getinstallflexsudoapt-getinstallbisonsudoapt-getinstallautoconfsudoapt-getinstalltexinfosudoapt-getinstallsubversionsudoapt-getinstalllibncurses5-devsudoapt-getinstallgit-coresudoapt-getinstallasciidoc(文件比较大,耐心等待)
3、 新建一个openwrt目录,使用命令:mkdiropenwrtsudochmod777openwrt 接下来的所有命令都在/openwrt目录下运行(编译系统的绝对路径中不能含有空格)。
4、 下载OpenWrt源码: 通过git来下载OpenWrtbleedingedge 从官方源下载:gitclonegit://git.openwrt.org/openwrt.git gitclonegit://git.openwrt.org/15.05/openwrt.git,下载时间比较漫长,请耐心等待。
5、 添加软件扩展包: cd openwrt/进入/home/kevinfan/openwrt/openwrt目录,可以找到feeds.conf.default文件,将feeds.conf.default修改为feeds.conf,使用以下命令: cpfeeds.conf.defaultfeeds.conf 得到feeds.conf文件
6、 更新扩展,安装扩展:./scripts/feedsupdate-a./scripts/feedsi荏鱿胫协nstall-a系统提示:WARNING: No feed for package 'librt' found, maybe it's already part of the standard packages?WARNING: No feed for package 'libpthread' found, maybe it's already part of the standard packages?WARNING: No feed for package 'lua' found, maybe it's already part of the standard packages?WARNING: No feed for package 'libc' found, maybe it's already part of the standard packages?WARNING: No feed for package 'libssp' found, maybe it's already part of the standard packages?
7、 测试下编译环境,使用命令: makedefconfig系统提示:Build dependency: Please install the openssl library (with development headers)/home/kevinfan/openwrt/openwrt/include/prereq.mk:12: recipe for target 'prereq' failedPrerequisite check failed. Use FORCE=1 to override./home/kevinfan/openwrt/openwrt/include/toplevel.mk:151: recipe for target 'staging_dir/host/.prereq-build' failedmake: *** [staging_dir/host/.prereq-build] Error 1请安装openssl库
8、 进openssl官网:http://www.openssl.org 下载页面:http://www.openssl.org/source/ 选择最新版本下载,用WinSCP上传至Ubuntu系统中,这里小编放在Downloads:openssl-1.1.0-pre5.tar.gz
9、解压:tar–zxvfopenssl-1.1.0-pre5.tar.gz,解压目录为:openssl-1.1.0-pre5然后进入到openssl-1.1.0-pre5,进行配置、编译、安装。配置 ./configure或./config编译 make安装makeinstall如果提示无权限,可以加上sudo在执行,接着只要等到编译安装完成即可。
10、 重新测试下编译环境,使用命令: makedefconfig 系统提示:configuration written to .config(配置写入config)。
11、 接着我们输入命令: makemenuconfig 如果一切正常,会出现一个配置菜单,可以选择要编译的固件平台、型号,还能选择固件中要添加的功能和组件,至此编译环境就搭建好了。