本帖最后由 wangsir6688 于 2022-5-5 22:21 编辑
每一步都根据官网提示操作,屡屡受挫!
Downloading a cross-compiling build environmentThis usually comes down to the following steps: Download and extract the SDK toolchain for your device. The toolchain must match the exact OpenWRT version installed in your device. Toolchain for official OpenWRT images can be downloaded from [color=var(--color-accent-fg)]https://downloads.openwrt.org Build the toolchain: run make menuconfig, save the configuration, then run make to build the cross compiling tools Download the feeds with ./scripts/feeds update -a
[color=var(--color-accent-fg)]CompilationThese instructions are for building the current checked out version of the n2n source (The generally used OpenWRT alternative is to download a tar.gz file of a specific n2n version, but that is not as suitable for development or local builds) You need both the openwrt repository and the n2n repository checked out for this. In these instructions, we assume that openwrt is the directory where your openwrt checkout is located and n2n is the directory for the n2n repository.
git clone https://github.com/ntop/n2n n2n #openwrt同级目录下载n2n源码
N2N_PKG_VERSION=$(n2n/scripts/version.sh) #选择n2n版本,$(n2n/scripts/version.sh)删掉,手填版本。不删默认最新版本。
export N2N_PKG_VERSION
cp -r n2n/packages/openwrt openwrt/package/n2n #拷贝源码至package目录
cd openwrt
make menuconfig # select Network -> VPN -> n2n-edge and n2n-supernode make menuconfig菜单勾选,建议用<M>
make package/n2n/clean V=s #清理之前编译
make package/n2n/prepare USE_SOURCE_DIR=../n2n V=s#预编译
报错:
(注意这步要改下 “USE_SOURCE_DIR=”路径,我这里是USE_SOURCE_DIR=/home/openwrt/n2n/,不改会报错。
make package/n2n/compile V=s
(这步也会报错)
报错信息:
CFLAGS="-Os -pipe -fno-caller-saves -fno-plt -fhonour-copts
-Wno-error=unused-but-set-variable -Wno-error=unused-result -fmacro-prefix-map=/home/openwrt/openwrt/build_dir/target-x86_64_musl/n2n-HEAD=n2n-HEAD
-Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro
-I/home/openwrt/openwrt/staging_dir/toolchain-x86_64_gcc-11.2.0_musl/usr/include
-I/home/openwrt/openwrt/staging_dir/toolchain-x86_64_gcc-11.2.0_musl/include/fortify
-I/home/openwrt/openwrt/staging_dir/toolchain-x86_64_gcc-11.2.0_musl/include "
CXXFLAGS="-Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable
-Wno-error=unused-result -fmacro-prefix-map=/home/openwrt/openwrt/build_dir/target-x86_64_musl/n2n-HEAD=n2n-HEAD
-Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro
-I/home/openwrt/openwrt/staging_dir/toolchain-x86_64_gcc-11.2.0_musl/usr/include
-I/home/openwrt/openwrt/staging_dir/toolchain-x86_64_gcc-11.2.0_musl/include/fortify
-I/home/openwrt/openwrt/staging_dir/toolchain-x86_64_gcc-11.2.0_musl/include
" LDFLAGS="-L/home/openwrt/openwrt/staging_dir/toolchain-x86_64_gcc-11.2.0_musl/usr/lib
-L/home/openwrt/openwrt/staging_dir/toolchain-x86_64_gcc-11.2.0_musl/lib -znow -zrelro "
make -j1 -C /home/openwrt/openwrt/build_dir/target-x86_64_musl/n2n-HEAD/.
AR="x86_64-openwrt-linux-musl-gcc-ar" AS="x86_64-openwrt-linux-musl-gcc -c -Os -pipe -fno-caller-saves -fno-plt -fhonour-copts
-Wno-error=unused-but-set-variable -Wno-error=unused-result -fmacro-prefix-map=/home/openwrt/openwrt/build_dir/target-x86_64_musl/n2n-HEAD=n2n-HEAD
-Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro" LD=x86_64-openwrt-linux-musl-ld NM="x86_64-openwrt-linux-musl-gcc-nm
" CC="x86_64-openwrt-linux-musl-gcc" GCC="x86_64-openwrt-linux-musl-gcc" CXX="x86_64-openwrt-linux-musl-g++" RANLIB="x86_64-openwrt-linux-musl-gcc-ranlib"
STRIP=x86_64-openwrt-linux-musl-strip OBJCOPY=x86_64-openwrt-linux-musl-objcopy OBJDUMP=x86_64-openwrt-linux-musl-objdump
SIZE=x86_64-openwrt-linux-musl-size CROSS="x86_64-openwrt-linux-musl-" ARCH="x86_64" ; make[3]: Entering directory '/home/openwrt/n2n'Build for version: 3.1.1-14-g3fa0fa1x86_64-openwrt-linux-musl-gcc -I./include -I/home/openwrt/openwrt/staging_dir/target-x86_64_musl/usr/include -Wall -c -o src/edge.o src/edge
.ccc1: note: someone does not honour COPTS correctly, passed 0 times
x86_64-openwrt-linux-musl-gcc -I./include -I/home/openwrt/openwrt/staging_dir/target-x86_64_musl/usr/include -Wall -c -o src/management.o src/management
.ccc1: note: someone does not honour COPTS correctly, passed 0 timesIn file included from src/management.h:11,
from src/management.c:17:./include/n2n_typedefs.h:425:5: error: unknown type name 'time_t' 425 | time_t uptime; | ^~~~~~./include/n2n_typedefs.h:450:5: error: unknown type name 'time_t' 450 | time_t last_seen; | ^~~~~~./include/n2n_typedefs.h:451:5: error: unknown type name 'time_t' 451 | time_t last_p2p; | ^~~~~~./include/n2n_typedefs.h:452:5: error: unknown type name 'time_t' 452 | time_t last_sent_query; | ^~~~~~./include/n2n_typedefs.h:457:5: error: unknown type name 'time_t' 457 | time_t uptime; | ^~~~~~
#编译(这一步也会报错,方法是cp /openwrt/staging_dir/toolchain-x86_64_gcc-11.2.0_musl里的include和lib文件夹到/openwrt/staging_dir/toolchain-x86_64_gcc-11.2.0_musl/usr目录,覆盖原文件。)
原因是gcc编译无法识别time_t 函数,查看GCC链接库文件位置没有头文件和库文件,手动COPY库文件、头文件进去。
n2n/include/n2n_typedefs.h文件打开添加一行 #include <time.h>。
有不对的地方还请大佬指点。 安装包奉上
|