- Install
git
, to conveniently download the OpenWrt source code, andbuild tools
to do the cross-compilation process:
Some feeds might not available over git but only viaapt-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
添加补丁
```
问题3(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
```
问题4(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
```
```
undefined reference to `makedev'
#include<sys/sysmacros.h>
```
问题6(php添加mod编译不通过)
-----------------------
#### 解决:
```
Makefile添加
EXTRA_CFLAGS = -fPIC
make clean
```
```
copy_file_range
copy_file_chunk
```
问题7 (glib/gdate.c)
-----------------------
`` gdate.c:2497:7: error: format not a string gdate.c:2497:7: error: format not a strinliteral, format string not ``
#### 解决:
```
checked [-Werror=format-nonliteral]
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
```
问题8 (e2fsprogs)
-----------------------
`` create_inode.c:395:18: error: conflicting types for 'copy_file_range' ``
#### 解决:
```
misc/create_inode.c中的头文件注释掉
//#include <unistd.h>
```
问题9 (gcc版本)
-----------------------
`` error: 'const char* libc_name_p(const char*, unsigned int)' redeclared inline with 'gnu_inline' attr ``
#### 解决:
```
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=ec1cc0263f156f70693a62cf17b254a0029f4852
```