- Install
git
, to conveniently download the OpenWrt source code, andbuild tools
to do the cross-compilation process:apt-get update sudo apt-get install git-core build-essential libssl-dev libncurses5-dev unzip
subversion
(short:svn
) ormercurial
. If you want to obtain their source-code, you need to install svn and mercurial as well:sudo apt-get install subversion mercurial
-
for information about the build tools see
make
and build-essential -
for information about git see
git(7)
-
for information about the subversion tool see
svn
and subversion documentation (multiple languages)
-
- Download the OpenWrt bleeding edge(trunk Version) with
git
(see Downloading Sources for more options!):git clone https://git.openwrt.org/openwrt/openwrt.git
this creates a directory 'openwrt', which is the OpenWrt Buildroot build-directory
the OpenWrt toolchain "OpenWrt Buildroot" is included - (optional) Download and install all available "feeds" (see OpenWrt Feeds for more options!):
cd openwrt && ./scripts/feeds update -a && ./scripts/feeds install -a
- Make OpenWrt Buildroot check for missing packages on your build-system using one of the following commands:
make defconfig make prereq make menuconfig
There you will need to select what you want to compile.
- Proceed with build (i.e. cross-compile the downloaded sources to binaries)
After the cross-compilation process the ''trunk''-directory contained 244,451 files with a total size of 3.2GiB!
其他版本地址:
openwrt: http://git.openwrt.org/
lede (目前又合併到openwrt了): https://git.lede-project.org/
dl目錄下載:http://downloads.openwrt.org.cn/sources/
各個系統版本openwrt編譯可能遇到問題
問題1(libc)
gconvert.c:55:2: error: #error GNU libiconv not in use but included iconv.h is from libiconv
解決:
cd /build_dir/host/pkg-config-0.28/glib
./configure --enable-iconv=no --with-libiconv=gnu
make
問題2(automake):
Unescaped left brace in regex is illegal here in regex; marked by <-- HERE in m/\${ <-- HERE ([^ \t=:+{}]+)}/ at ./bin/a utomake.tmp line 3938.
解決:
https://git.lede-project.org/?p=source.git;a=commit;h=92c80f38cff3c20388f9ac13d5196f2745aeaf77
添加補丁
問題4(flex):
make[6]: *** [Makefile:1696: stage1scan.c] Segmentation fault (core dumped)
解決:
https://git.lede-project.org/?p=source.git;a=commitdiff;h=0fb14a2b1ab2f82ce63f4437b062229d73d90516
進到目錄運行 autoreconf -ivf
問題3(n2n編譯不通過)
結構體重複定義
解決:
n2n補丁添加:
diff -ruN a/n2n.c b/n2n.c
--- a/n2n.c 2009-07-17 19:43:58.000000000 +0800
+++ b/n2n.c 2017-11-11 11:32:39.452257854 +0800
@@ -334,7 +334,7 @@
¦| }
¦| snprintf(out_buf, sizeof(out_buf), "%s%s", extra_msg, buf);
- syslog(LOG_INFO, out_buf);
+ syslog(LOG_INFO, "%s", out_buf);
¦|} else {
¦| snprintf(out_buf, sizeof(out_buf), "%s [%11s:%4d] %s%s", theDate, file, line, extra_msg, buf);
¦| printf("%s\n", out_buf);
diff -ruN a/n2n.h b/n2n.h
--- a/n2n.h 2009-09-06 13:15:29.000000000 +0800
+++ b/n2n.h 2017-11-11 11:31:56.641652210 +0800
@@ -65,6 +65,7 @@
#ifdef __linux__
#include <linux/if.h>
#include <linux/if_tun.h>
+#define __n2nlede__
#endif
#ifdef __FreeBSD__
修改 staging_dir/toolchain-mips_24kc_gcc-5.4.0_musl/include/net/ethernet.h
#ifndef __n2nlede__
#include <netinet/if_ether.h>
#endif
問題5(m4/findutils)
#error "Please port gnulib freadahead.c to your platform! Look at the definition of fflush, fread, ungetc on your system, then report this to bug-gnulib."
解決:
進入出錯目錄:
<m4>
sed -i 's/IO_ftrylockfile/IO_EOF_SEEN/' lib/*.c
echo "#define _IO_IN_BACKUP 0x100" >> lib/stdio-impl.h
<findutils>
sed -i 's/IO_ftrylockfile/IO_EOF_SEEN/' gl/lib/*.c
echo "#define _IO_IN_BACKUP 0x100" >> gl/lib/stdio-impl.h
sed -i '/unistd/a #include <sys/sysmacros.h>' gl/lib/mountlist.c
問題6(php添加mod編譯不通過)
解決:
Makefile添加
EXTRA_CFLAGS = -fPIC
make clean