最近在编译openwrt的时候,遇到了一些问题,问题如下:
1. CMake编译出现-- The C compiler identification is unknown
重新检查环境,看是否是64位系统
2. Download failed
在 /home/work/openwrt-hiwooya/scripts/download.pl的
L182行加上push @mirrors, "https://www.kernel.org/pub/$dir";
3. 64位系统编译不过
需要在32位环境搭建的基础上在安装以下软件包:
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386
基于此,对openwrt的编译做个详细说明,注意点,openwrt编译的时候禁用root用户,必须用非root用户登录
系统:ubuntu 64位
注意点:
1. 请使用一个非root用户来完成这些工作! 2. 这里的所有命令都在OpenWrt编译系统的根目录下运行(例如 ~/openwrt/trunk/ )3. 编译系统的绝对路径中不能含有空格! 4. 如果你使用root用户下载了源码,请把你下载来的源码的所有者更改为一个非root用户。( sudo chown -R user:user /openwrt/ ) |
编译步骤:
1. 源码下载
新建文件夹openwrt
chmod 777 openwrt
cd openwrt
git clone https://git.openwrt.org/openwrt/openwrt.git/
openwrt的目录结构:
/config : configuration files for menuconfig
/include : makefile configuration files
/package : packages makefile and configuration
/scripts : miscellaneous scripts used throughout the build process
/target : makefile and configuration for building imagebuilder, kernel, sdk and the toolchain built by buildroot.
/toolchain : makefile and configuration for building the toolchain
/tools : miscellaneous tools used throughout the build process
2. 安装依赖库
sudo apt install subversion g++ zlib1g-dev build-essential git python time
sudo apt install libncurses5-dev gawk gettext unzip file libssl-dev wget
sudo apt install libelf-dev
如果是ubuntu 18.04 or later
sudo apt install build-essential libncurses5-dev python unzip
Ubuntu 12.04LTS:
sudo apt-get install build-essential subversion git-core libncurses5-dev zlib1g-dev gawk flex quilt libssl-dev xsltproc libxml-parser-perl mercurial bzr ecj cvs unzip
Ubuntu 64bit:
sudo apt-get install build-essential subversion libncurses5-dev zlib1g-dev gawk gcc-multilib flex git-core gettext libssl-dev
3. (可选) 下载并安装可用的feeds
./scripts/feeds update -a
./scripts/feeds install -a
4. 配置
先make distclean
再
make menuconfig (推荐使用此命令)
或者
make defconfig
或者
make prereq
//如果以上3个命令都运行了,编译会出错!
选择正确的型号
顺便把luci web跟sftp服务器配置上,这两个都是后面开发会用到的
Network ---> SSH ---> <*> openssh-sftp-server
LuCI --->1. Collections ---> <*> luci --op自带luci web
LuCI --->2. Modules --->Translations ---><*> Chinese (zh-cn) --支持中文显示
5. 编译
make V=s或者make V=99