其他分享
首页 > 其他分享> > vpp2101交叉编译方法

vpp2101交叉编译方法

作者:互联网

1环境和条件:

1.1开发机:

CentOS Linux release 8.3.2011

Linux localhost.localdomain 4.18.0-240.22.1.el8_3.x86_64 #1 SMP Thu Apr 8 19:01:30 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

1.2目标机:

Linux Switch 3.14.57_v1.0 #2 SMP Mon May 17 18:29:08 CST 2021 aarch64_be GNU/Linux

1.3工具链:

工具链下载地址:

https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads

下载:

gcc-arm-10.2-2020.11-x86_64-aarch64_be-none-linux-gnu.tar.xz

1.4 VPP

1.版本:2101

2.下载源码:

git clone https://gerrit.fd.io/r/vpp

3.check稳定发行版本:2101

git checkout -b stable/2101 origin/stable/2101

2安装vpp依赖工具库等

make install-dep

make install-ext-dep

3交叉编译

3.1工具链准备

工具链拷贝到开发机上面解压后,交叉编译 libuuid、openssl,并将结果生成到工具链的libc/usr目录:

交叉编译 libuuid:libuuid-1.0.3.tar.gz

CC="aarch64_be-none-linux-gnu-gcc" ./configure --host=x86_64 --prefix=/home/guoqixin/gcc-arm-10.2-2020.11-x86_64-aarch64_be-none-linux-gnu/aarch64_be-none-linux-gnu/libc/usr

交叉编译 openssl:openssl-OpenSSL_1_0_1e.tar.gz

CC="aarch64_be-none-linux-gnu-gcc" ./config no-asm shared --prefix=/home/guoqixin/gcc-arm-10.2-2020.11-x86_64-aarch64_be-none-linux-gnu/aarch64_be-none-linux-gnu/libc/usr

去掉 Makefile 里面的 -m64 编译选项

3.2在vpp中指定工具链相关信息

vim vpp/src/CMakeLists.txt:

1.添加:必须在 project(vpp C) 前面添加:工具链路径根据自身情况做修改

#####################################################################

set(CMAKE_SYSTEM_NAME Linux)

set(CMAKE_SYSTEM_PROCESSOR aarch64)

set(CMAKE_SYSROOT /home/guoqixin/gcc-arm-10.2-2020.11-x86_64-aarch64_be-none-linux-gnu/aarch64_be-none-linux-gnu/libc)

set(tools /home/guoqixin/gcc-arm-10.2-2020.11-x86_64-aarch64_be-none-linux-gnu)

set(CMAKE_C_COMPILER ${tools}/bin/aarch64_be-none-linux-gnu-gcc)

set(CMAKE_CXX_COMPILER ${tools}/bin/aarch64_be-none-linux-gnu-g++)

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)

set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)

set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

#####################################################################

project(vpp C)

2. 删除:删掉下面的 -Werror 编译选项

if (CMAKE_BUILD_TYPE)

  set(CMAKE_C_FLAGS "-g -fPIC -Werror -Wall ${CMAKE_C_FLAGS}")

endif()

3.3编译

make build-release

编译结果在:

vpp/build-root/install-vpp-native/vpp

4目标机

将编译结果:vpp/build-root/install-vpp-native/vpp目录打包,拷贝到目标机;

同时将工具链的:

gcc-arm-10.2-2020.11-x86_64-aarch64_be-none-linux-gnu/aarch64_be-none-linux-gnu/libc 目录打包拷贝到目标机

运行:

LD_LIBRARY_PATH=[工具链路径]/libc/lib64:[工具链路径]/libc/usr/lib64  [工具链路径]/libc/lib/ld-linux-aarch64_be.so.1  [vpp路径]/vpp/bin/vpp  -c  startup.conf

5 各种编译问题处理

1、问题:

cmake: symbol lookup error: cmake: undefined symbol: archive_write_add_filter_zstd

解决办法:

yum remove libarchive*

wget https://github.com/libarchive/libarchive/releases/download/3.5.1/libarchive-3.5.1.tar.xz

tar -xvf libarchive-3.5.1.tar.xz

cd libarchive-3.5.1

./configure --prefix=/usr --disable-static && make

sudo make install

cd .. && rm -rf libarchive-3.5.1 && rm libarchive-3.5.1.tar.xz

git tag -d v21.10-rc0

git tag -a v21.10-rc0 -m "v21.10-rc0"

git describe

标签:none,CMAKE,vpp,交叉,aarch64,gnu,编译,linux,vpp2101
来源: https://blog.csdn.net/guoqixin2008/article/details/122415704