n2n koolshare lede x64 cross compilation

n2n koolshare lede x64 cross compilation

First of all, I would like to thank the original author of this blog post: http://www.lucktu.com/archives/778.html

Install cmake3.6

To compile the new version of n2n, you need to use cmake3 version, and the cmake version installed by yum of centos7 is 2.8, you need to install cmake manually.
First uninstall cmake

yum remove cmake

Download cmake3.6 https://cmake.org/files/v3.6/cmake-3.6.0-Linux-x86_64.tar.gz
The download is not an installation package, but an executable file. After decompression, add the cmake directory to PATH

vim /etc/bashrc
#在文件末尾添加
export PATH=$PATH:/usr/local/cmake3.6/bin

download sdk (toolchain)

Download the sdk of the corresponding version of openwrt. The latest sdk of koolshare LEDE x64 is LEDE17.01.6. The
download address is http://downloads.openwrt.org/releases/17.01.6/targets/x86/64/lede-sdk-17.01.6 -x86-64_gcc-5.4.0_musl-1.1.16.Linux-x86_64.tar.xz

decompressed to the directory /home/wjm/compiler/sdk/lede17.01.5_gcc-5.4.0

cross compile openssl

Download address: http://distfiles.macports.org/openssl/
Unzip to the directory /home/wjm/compiler/lib/openssl-1.1.1d
Enter the openssl directory, set the generation path, no need to generate assembly

./config no-asm shared --prefix=/home/wjm/compiler/sdk/lede17.01.5_gcc-5.4.0/staging_dir/toolchain

Then modify the MakeFile file to specify the cross-compiled gcc

CROSS_COMPILE=x86_64-openwrt-linux-
CC=$(CROSS_COMPILE)gcc
CXX=$(CROSS_COMPILE)g++
CPPFLAGS=
CFLAGS=-Wall -O3
CXXFLAGS=-Wall -O3
LDFLAGS=
EX_LIBS=

At the same time, delete -m64, two places need to be deleted.

CNF_CFLAGS=-pthread -m64
CNF_CXXFLAGS=-std=c++11 -pthread -m64

Compile and install

make
sudo make install

cross compile n2n

Download the source code, I plan to compile the v2s version, the source address is n2n_v2 under https://github.com/meyerd/n2n.git

git clone https://github.com/meyerd/n2n.git

Enter the n2n_v2 directory, use cmake to build Makefile,
modify CMakeLists.txt and set two variables at the top

SET(CMAKE_CXX_COMPILER "x86_64-openwrt-linux-g++")
SET(CMAKE_C_COMPILER "x86_64-openwrt-linux-gcc")

project(n2n)
cmake_minimum_required(VERSION 2.6)

To modify the environment variable, you can add the environment variable to bashrc as needed or execute it only in the current shell (if it is only temporarily compiled),
add STAGING_DIR, modify PATH, and add the toolchain bin to PATH

export STAGING_DIR=/home/wjm/compiler/sdk/lede17.01.5_gcc-5.4.0/staging_dir
export PATH=$STAGING_DIR/toolchain/bin:$PATH

Create a new build directory in the source code directory to store the compilation results

mkdir build

Run cmake, specify the compilation type, and specify the installation directory as build

cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=build
make
sudo make install

Guess you like

Origin blog.csdn.net/wangjm1982/article/details/102572919