openwrt编译环境搭建

 

1、虚拟机安装

         请参考网络上的资料进行安装。

 

2、ubuntu安装

         请参考网络上的资料进行安装。

 

3、ubuntu下安装相关的编译环境(若是编译环境没有准备好,在后来的操作中会出现一些问题)

         sudoapt-get install g++

         sudoapt-get install libncurses5-dev

         sudoapt-get install zlib1g-dev

         sudoapt-get install bison

         sudoapt-get install flex

         sudoapt-get install unzip

         sudoapt-get install autoconf

         sudoapt-get install gawk

         sudoapt-get install make

         sudoapt-get install gettext

         sudoapt-get install gcc

         sudoapt-get install binutils

         sudoapt-get install patch

         sudoapt-get install bzip2

         sudoapt-get install libz-dev

         sudoapt-get install asciidoc

         sudoapt-get install subversion

         sudoapt-get install sphinxsearch

         sudoapt-get install libtool

         sudoapt-get install sphinx-common

         sudoapt-get install libssl-dev

         sudoapt-get install libssl0.9.8

(https://yq.aliyun.com/articles/33263)/

      sudo apt-get installgcc 
      sudoapt-get install g++ 
      sudo apt-getinstall binutils 
      sudoapt-get install patch 
      sudoapt-get install bzip2 
      sudoapt-get install flex 
      sudoapt-get install bison 
      sudoapt-get install make 
      sudoapt-get install autoconf 
      sudoapt-get install gettext 
      sudoapt-get install texinfo 
      sudoapt-get install unzip 
      sudoapt-get install sharutils 
      sudoapt-get install subversion 
      sudoapt-get install libncurses5-dev 
      sudoapt-get install ncurses-term 
      sudoapt-get install zlib1g-dev 
      sudoapt-get install gawk
      sudoapt-get install asciidoc
      sudoapt-get install libz-dev

 

4、安装git绑定ssh密钥(https://www.linuxidc.com/Linux/2016-09/135527.htm)

         sudoapt-get install git

         参考网上资料安装git并在github上注册账号,并将

5、openwrt源码下载

         git clonehttps://www.github.com/openwrt/openwrt

问题:

 

6、安装feeds安装包,(经常会出现问题3中的问题,所以在执行该指令之前先将feeds.conf.default中进行内容修改(将https:\\改为git:\\)。)

         ./scripts/feedsupdate -a

         ./scripts/feedsinstall -a

 

7、配置openwrt

         7.1、执行makemenuconfig指令

         配置openwrt编译目标板,

                   target选择AtherosAR7xxx/AR9xxx

                   subtarget         选择Subtarget(Generic)

                   targetprofile选择Atheros DB120...

                   LuCI暂不配置

 

8、指令加载LuCI到内核

       8.1、把LuCI编译进内核指令:
       ./scripts/feeds update packagesluci
       ./scripts/feeds install -a -p luci

 

9、编译openwrt

         make-j1 V=s

         生成的镜像文件在t/bin/targets/ar71xx/generic目录下的.bin文件,我的目标板生成的是:

openwrt-ar71xx-generic-db120-squashfs-sysupgrade.bin

 

 

遇到的问题:

问题1:

内容:安装git过程中遇到的问题:在执行git clone https://www.github.com/openwrt/openwrt时提示提示Permission denied(publickey)问题;

原因:在生成ssh密钥之后,复制到github的SSH中之后,并没有在ubuntu下将私钥添加;

解决方法:ssh密钥id_rs文件的目录下执行指令:ssh-add   ~/.ssh/id_rs,这个具体操作可参考链接(https://www.cnblogs.com/chuyanfenfei/p/8035067.html)

 

问题2:

内容:使用指令git clone git://git.openwrt.org/14.07/openwrt.git出现错误如下:

         Cloninginto 'openwrt'...

         fatal:unable to connect to git.openwrt.org:

         git.openwrt.org[0:46.101.214.210]: errno=No error

原因:应该是git链接不正确,使用指令可成功下载:

(参考链接:https://dev.openwrt.org/wiki/GetSource)

BB版本:git clone -bbarrier_breaker git://github.com/openwrt/openwrt.git

CC版本:

最终我是采用openwrt官网上提供的链接下载主干代码进行编译的:

git指令:git clonehttps://www.github.com/openwrt/openwrt

(参考链接:https://wiki.openwrt.org/zh-cn/doc/howto/build)

 

问题3:

内容:在使用./scripts/feeds update -a指令执行安装软件包的时候遇到:fatal:HTTP request failed;

原因:feeds.conf.default文件中的将里面所有https替换成git便可。

解决方法:将openwrt目录下的feeds.conf.default文件中的将里面所有https替换成git便可。

保存修改后在执行./scripts/feeds update -a指令便可。

 

问题4:awk: include/scan.awk: line 21: function asort never defined

原因:/bin/sh的链接到/bin/dash,而不是/bin/bash(可以用命令ls /bin/sh -lh查看链接的时bash还是dash)

解决方法:(可参考链接:http://blog.csdn.net/smilettxp/article/details/19118057?reload)

         修改sh默认指向到/bin/bash,如下:

   sudo dpkg-reconfigure dash 选择no,即可。

         awk:line的解决办法是安装gnuawk,如下:

         sudoapt-get install gawk 即可。

 

问题5:

内容:Build dependency: Please install a static zlib. (Missing libz.a orzlib.h)

原因:没有安装需要的库;

解决方法:(参考:http://blog.csdn.net/mrwangwang/article/details/38977485)

安装需要的包sudo apt-get install libncurses5-dev  zlib1g-dev  gawk flex  patch   git-core g++   subversion (注意zlib1g-dev中的1是1不是l);

 

问题6:

内容:

                     Error when bootstrapping CMake:

                     Cannot find a C++ compiler supporting C++11on this system.

                            Pleasespecify one using environment variable CXX.

                            Seecmake_bootstrap.log for compilers attempted.

原因:需要知道c++11标准在gcc版本在4.7以及之上才支持

解决方法:在ubuntu中更新4.7版本以上的gcc和g++(参考链接:https://blog.csdn.net/ture_dream/article/details/52651746);安装了4.7版本的gcc、g++编译器之后,解决了上一个问题,但是又出现了新的问题,因此查了一下gcc/g++的最新版本的编译器为4.8,重新安装了4.8版本的编译器(参考链接:https://blog.csdn.net/haluoluo211/article/details/71141093);

 

问题7:

内容:在执行make的过程中遇到以下问题:

         make[5]:*** [s-automata] Error 137

         make[5]:Leaving directory`/home/sky/openwrt/build_dir/toolchain-mips_24kc_gcc-7.3.0_musl/gcc-7.3.0-initial/gcc'

         make[4]:*** [all-gcc] Error 2

         make[4]:Leaving directory`/home/sky/openwrt/build_dir/toolchain-mips_24kc_gcc-7.3.0_musl/gcc-7.3.0-initial'

         make[3]:***[/home/sky/openwrt/build_dir/toolchain-mips_24kc_gcc-7.3.0_musl/gcc-7.3.0-initial/.built]Error 2

         make[3]:Leaving directory `/home/sky/openwrt/toolchain/gcc/initial'

         make[2]:*** [toolchain/gcc/initial/compile] Error 2

         make[2]:Leaving directory `/home/sky/openwrt'

         make[1]:***[/home/sky/openwrt/staging_dir/toolchain-mips_24kc_gcc-7.3.0_musl/stamp/.toolchain_compile]Error 2

         make[1]:Leaving directory `/home/sky/openwrt'

         make:*** [world] Error 2

原因:内存不足(参考链接:https://blog.csdn.net/qianguozheng/article/details/52266267);

解决方法:

         1、增加虚拟内存,swap分区;

         2、把/etc/sysctl.conf里的swappiness设成60了,swappiness是虚拟内存使用率;

         3、还有一个就是更新gcc工具。

         我的解决方法是将虚拟机的设置中将硬盘和内存容量都扩倍了。

 

问题8:

内容:在执行make的过程中遇到以下问题报错:

         WARNING:Makefile 'package/feeds/luci/luci-proto-vpnc/Makefile' has a dependency on'vpnc', which does not exist

         WARNING:Makefile 'package/feeds/routing/nodogsplash2/Makefile' has a dependency on 'libmicrohttpd-no-ssl',which does not exist

         WARNING:Makefile 'package/feeds/routing/ohybridproxy/Makefile' has a dependency on'mdnsd', which does not exist

         WARNING:Makefile 'package/feeds/routing/olsrd/Makefile' has a dependency on 'libgps',which does not exist

         WARNING:Makefile 'package/feeds/telephony/restund/Makefile' has a dependency on'libmysqlclient', which does not exist

         WARNING:Makefile 'package/feeds/telephony/sipgrep/Makefile' has a dependency on'libpcre', which does not exist

         WARNING:Makefile 'package/feeds/telephony/sngrep/Makefile' has a dependency on'libpcre', which does not exist

         WARNING:Makefile 'package/feeds/telephony/spandsp/Makefile' has a dependency on'libtiff', which does not exist

         WARNING:Makefile 'package/feeds/telephony/yate/Makefile' has a dependency on'perlbase-data', which does not exist

         WARNING:Makefile 'package/feeds/telephony/yate/Makefile' has a dependency on'alsa-lib', which does not exist

         WARNING:Makefile 'package/feeds/telephony/yate/Makefile' has a dependency on'libmysqlclient-r', which does not exist

         WARNING:Makefile 'package/feeds/telephony/yate/Makefile' has a dependency on 'libpq',which does not exist

         WARNING:Makefile 'package/feeds/telephony/yate/Makefile' has a dependency on'libsqlite3', which does not exist

原因:可能由于网络问题,在下载./scripts/feeds update -a 和安装       ./scripts/feeds install -a软件包的过程中出现下载失败的问题。

解决方法:保存网络良好,再次执行该语句./scripts/feeds uninstall freeswitch或者多次执行./scripts/feedsupdate -a和./scripts/feeds install -a语句。

 

问题9:

内容:在编译openwrt的过程中,出现以下问题:

check_data_file_clashes:Package libustream-opensslwants to install file

/home/sky/openwrt2/openwrt/build_dir/target-mips_24kc_musl/root-ar71xx/lib/libustream-ssl.so,       But that file is already providedby package  * libustream-mbedtls

* opkg_install_cmd: Cannot install packageluci-ssl-openssl.

原因:在make menuconfig进行配置编译选项中,LuCI->Collection下的ibustream-mbedtls和luci-ssl-openssl两个选项都进行了选择,其实只要进行其中一个选择便可。

解决方法:make disclean,重新make menuconfig进行配置LuCI,然后重新编译make;其实最保险的做法是在不进行LuCI的配置选项选择,通过以下指令将LuCI编译进内核中:

         ./scripts/feedsupdate packages luci

         ./scripts/feedsinstall -a -p luci

 

 

 

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐