vpp之源码编译

本文介绍了在CentOS 7.5环境下使用virtualenv虚拟环境编译VPP项目的步骤。包括安装依赖、设置虚拟环境及编译文档等内容,并解决了编译过程中遇到的依赖问题。

服务器系统

[ych@localhost ~]$ cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)

$uname -a
Linux air5005 3.10.0-862.14.4.el7.x86_64 #1 SMP Wed Sep 26 15:12:11 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

下载vpp

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

编译vpp文档

使用virtualenv虚拟环境,编译vpp文件
1.virtualenv虚拟环境安装:

$ sudo python -m pip install --user virtualenv 
$ sudo python -m virtualenv env
$ sudo source env/bin/activate
$ sudo pip install -r docs/etc/requirements.txt

pip install -r docs/etc/requirements.txt的时候,如果出现某个软件安装失败,
需要手动安装:
Cannot uninstall ‘pyparsing’. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

下面软件是安装时候出现异常,需要手动安装的

sudo pip install -I pyparsing==2.3.0
sudo pip install -I packaging==18.0
sudo pip install -I requests==2.21.0

2.编译html文件

(env) [ych@localhost vpp]$ cd docs/
(env) [ych@localhost docs]$ 
(env) [ych@localhost docs]$ make html
Running Sphinx v1.8.2
/usr/lib/python2.7/site-packages/sphinx/util/requests.py:72: UserWarning: Some links may return broken results due to being unable to check the Server Name Indication (SNI) in the returned SSL cert against the hostname in the url requested. Recommended to install requests-2.4.1+.
  'Some links may return broken results due to being unable to '
making output directory...
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 248 source files that are out of date
updating environment: 248 added, 0 changed, 0 removed
reading sources... [100%] usecases/vmxnet3                                                                                                                                                                        
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] usecases/vmxnet3                                                                                                                                                                         
generating indices... genindex
writing additional pages... search
copying images... [100%] _images/fib20fig6.png                                                                                                                                                                    
copying static files... done
copying extra files... done
dumping search index in English (code: en) ... done
dumping object inventory... done
build succeeded.

The HTML pages are in _build/html.

在这里插入图片描述

编译vpp

# if vpp<08.10
make install-dep
make bootstrap
make build        # or `make build-release`

# vpp 08.10+ (cmake)
make install-dep
make install-ext-deps
make build        # or `make build-release`

make install-dep和 install-ext-deps主要是安装编译需要的依赖库
make build 编译出来的版本包含了调试符号,可用于调试debug用
make build-release 编译已经发布出来的版本,进过了优化,不会创建任何调试符号

### VPP交叉编译教程 VPP(Vector Packet Processing)是一种高性能数据平面开发套件,通常用于网络功能虚拟化(NFV)环境。为了在不同的目标平台上部署VPP,需要进行交叉编译。以下是关于VPP交叉编译的相关信息和指南[^1]。 #### 1. 环境准备 在开始交叉编译之前,确保主机系统已安装必要的工具链和依赖项。例如,对于ARM架构的目标平台,可能需要安装`gcc-arm-linux-gnueabi`等工具链。此外,还需要安装以下软件包: ```bash sudo apt-get install build-essential cmake git libnuma-dev ``` #### 2. 获取VPP源码 从官方仓库克隆VPP的源代码: ```bash git clone https://gerrit.fd.io/r/vpp cd vpp ``` 确保检出所需的版本或分支[^2]。 #### 3. 配置交叉编译环境 创建一个配置文件来指定交叉编译工具链。例如,可以创建一个名为`build-root/config.env`的文件,并添加以下内容: ```bash export CC=arm-linux-gnueabihf-gcc export CXX=arm-linux-gnueabihf-g++ export LD=arm-linux-gnueabihf-ld export AR=arm-linux-gnueabihf-ar export RANLIB=arm-linux-gnueabihf-ranlib ``` 根据目标平台的具体需求调整工具链路径和名称[^3]。 #### 4. 编译VPP 使用CMake生成构建文件,并执行交叉编译: ```bash mkdir build && cd build cmake -DCMAKE_TOOLCHAIN_FILE=../build-root/toolchain.cmake .. make -j$(nproc) ``` 此处的`toolchain.cmake`文件应包含交叉编译工具链的配置信息[^4]。 #### 5. 验证编译结果 完成编译后,可以在`build`目录下找到生成的二进制文件。使用`file`命令检查二进制文件是否为目标架构: ```bash file build-root/install-vpp-native/vpp/bin/vpp ``` 输出应显示目标架构,例如`ARM`或`x86_64`[^5]。 #### 注意事项 - 确保目标平台的库和头文件与主机系统的版本兼容。 - 如果遇到依赖项问题,可能需要手动下载并交叉编译相关库。 ```python # 示例:验证Python脚本是否能加载交叉编译的动态库 import ctypes lib = ctypes.CDLL("path/to/cross-compiled-library.so") print(lib.some_function()) ```
评论 15
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值