参考:Github

安装p4c-bm:

sudo pip install -r requirements.txtsudo pip install -r requirements_v1_1.txt //if you are interested in compiling P4 v1.1 programssudo python setup.py install

测试:

p4c-bmv2 -h

弹出相关信息:

usage: p4c-bmv2 [-h] [--json JSON] [--pd PD] [--pd-from-json][--p4-prefix P4_PREFIX] [--field-aliases FIELD_ALIASES][--p4-v1.1] [--version] [--primitives PRIMITIVES][--plugin PLUGIN_LIST][--openflow-mapping-dir OPENFLOW_MAPPING_DIR][--openflow-mapping-mod OPENFLOW_MAPPING_MOD] [--keep-pragmas]sourcep4c-bm argumentspositional arguments:source                A source file to include in the P4 program.optional arguments:-h, --help            show this help message and exit--json JSON           Dump the JSON representation to this file.--pd PD               Generate PD C/C++ code for this P4 program in thisdirectory. Directory must exist.--pd-from-json        Generate PD from a JSON file, not a P4 file--p4-prefix P4_PREFIXP4 name use for API function prefix--field-aliases FIELD_ALIASESPath to file containing field aliases. In this file,each line contains a mapping with this format:"<alias> <full name of field>"--p4-v1.1             Run the compiler on a p4 v1.1 program--version, -v         show program's version number and exit--primitives PRIMITIVESA JSON file which contains additional primitivedeclarations--plugin PLUGIN_LIST  list of plugins to generate templates--openflow-mapping-dir OPENFLOW_MAPPING_DIRDirectory of openflow mapping files--openflow-mapping-mod OPENFLOW_MAPPING_MODOpenflow mapping module name -- not a file name--keep-pragmas        Propagate pragmas to JSON file when applicable

安装bmv2:

要求:

On Ubuntu 14.04, the following packages are required:automakecmakelibjudy-devlibgmp-devlibpcap-devlibboost-devlibboost-test-devlibboost-program-options-devlibboost-system-devlibboost-filesystem-devlibboost-thread-devlibevent-devlibtoolflexbisonpkg-configg++libssl-dev

以及Github中的一些工具,如thrift等,说的很详细了。

下载bmv2:

git clone https://github.com/p4lang/behavioral-model.git bmv2

安装依赖:

sh install_deps.sh

测试:

1. ./autogen.sh
2. ./configure
3. make
4. [sudo] make install  # if you need to install bmv2

make成功是这样子的:

Making all in tests
make[5]: Entering directory `/home/wasdns/bmv2/targets/simple_switch/tests'
Making all in .
make[6]: Entering directory `/home/wasdns/bmv2/targets/simple_switch/tests'
make[6]: Nothing to be done for `all-am'.
make[6]: Leaving directory `/home/wasdns/bmv2/targets/simple_switch/tests'
Making all in CLI_tests
make[6]: Entering directory `/home/wasdns/bmv2/targets/simple_switch/tests/CLI_tests'
make[6]: Nothing to be done for `all'.
make[6]: Leaving directory `/home/wasdns/bmv2/targets/simple_switch/tests/CLI_tests'
make[5]: Leaving directory `/home/wasdns/bmv2/targets/simple_switch/tests'
make[4]: Leaving directory `/home/wasdns/bmv2/targets/simple_switch'
make[3]: Leaving directory `/home/wasdns/bmv2/targets/simple_switch'
make[3]: Entering directory `/home/wasdns/bmv2/targets'
make[3]: Nothing to be done for `all-am'.
make[3]: Leaving directory `/home/wasdns/bmv2/targets'
make[2]: Leaving directory `/home/wasdns/bmv2/targets'
Making all in tools
make[2]: Entering directory `/home/wasdns/bmv2/tools'
rm -f bm_p4dbg bm_p4dbg.tmp
sed -e 's|@pythondir[@]|/usr/local/lib/python2.7/dist-packages|g' ./bm_p4dbg.in >bm_p4dbg.tmp
chmod +x bm_p4dbg.tmp
chmod a-w bm_p4dbg.tmp
mv bm_p4dbg.tmp bm_p4dbg
rm -f bm_CLI bm_CLI.tmp
sed -e 's|@pythondir[@]|/usr/local/lib/python2.7/dist-packages|g' ./bm_CLI.in >bm_CLI.tmp
chmod +x bm_CLI.tmp
chmod a-w bm_CLI.tmp
mv bm_CLI.tmp bm_CLI
rm -f bm_nanomsg_events bm_nanomsg_events.tmp
sed -e 's|@pythondir[@]|/usr/local/lib/python2.7/dist-packages|g' ./bm_nanomsg_events.in >bm_nanomsg_events.tmp
chmod +x bm_nanomsg_events.tmp
chmod a-w bm_nanomsg_events.tmp
mv bm_nanomsg_events.tmp bm_nanomsg_events
make[2]: Leaving directory `/home/wasdns/bmv2/tools'
make[2]: Entering directory `/home/wasdns/bmv2'
make[2]: Leaving directory `/home/wasdns/bmv2'
make[1]: Leaving directory `/home/wasdns/bmv2'

当make不成功的时候,一般是报.lo的错误,比如:

g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [packet.lo] Error 1
make[3]: Leaving directory `/home/wasdns/behavioral-model/src/bm_sim'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/wasdns/behavioral-model/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/wasdns/behavioral-model'
make: *** [all] Error 2

我的解决方法是,执行:

./configure 'CXXFLAGS=-O0 -g'

进入debug模式,github是这样描述的:

In 'debug mode', you probably want to disable compiler optimization and enable symbols in the binary

之后,跑样例:

make check

注意,如果出现有关nanomsg的问题,需要在命令前加上sudo。

我的结果:

make  check-TESTS
make[3]: Entering directory `/home/wasdns/bmv2/tests'
make[4]: Entering directory `/home/wasdns/bmv2/tests'
PASS: test_actions
PASS: test_checksums
PASS: test_expressions
PASS: test_conditionals
PASS: test_data
PASS: test_handle_mgr
PASS: test_p4objects
PASS: test_parser
PASS: test_phv
PASS: test_queue
PASS: test_queueing
PASS: test_tables
PASS: test_learning
PASS: test_pre
PASS: test_calculations
PASS: test_header_stacks
PASS: test_meters
PASS: test_ageing
PASS: test_counters
PASS: test_pcap
PASS: test_fields
PASS: test_devmgr
PASS: test_packet
PASS: test_extern
../test-driver: line 107: 56596 Aborted                 (core dumped) "$@" > $log_file 2>&1
FAIL: test_switch
PASS: test_target_parser
PASS: test_runtime_iface
PASS: test_bm_apps
PASS: test_stateful
make[5]: Entering directory `/home/wasdns/bmv2/tests'
Making all in .
make[6]: Entering directory `/home/wasdns/bmv2/tests'
make[6]: Nothing to be done for `all-am'.
make[6]: Leaving directory `/home/wasdns/bmv2/tests'
make[5]: Leaving directory `/home/wasdns/bmv2/tests'
============================================================================
Testsuite summary for bm 1.4.0-84ed92dd
============================================================================
# TOTAL: 29
# PASS:  28
# SKIP:  0
# XFAIL: 0
# FAIL:  1
# XPASS: 0
# ERROR: 0
============================================================================
See tests/test-suite.log
Please report to antonin@barefootnetworks.com
============================================================================
make[4]: *** [test-suite.log] Error 1
make[4]: Leaving directory `/home/wasdns/bmv2/tests'
make[3]: *** [check-TESTS] Error 2
make[3]: Leaving directory `/home/wasdns/bmv2/tests'
make[2]: *** [check-am] Error 2
make[2]: Leaving directory `/home/wasdns/bmv2/tests'
make[1]: *** [check-recursive] Error 1
make[1]: Leaving directory `/home/wasdns/bmv2/tests'
make: *** [check-recursive] Error 1

还是出现了一个Error,查看日志信息:

cd testsvim test-suite.log

日志如下:

=============================================bm 1.4.0-84ed92dd: tests/test-suite.log
=============================================# TOTAL: 29
# PASS:  28
# SKIP:  0
# XFAIL: 0
# FAIL:  1
# XPASS: 0
# ERROR: 0.. contents:: :depth: 2FAIL: test_switch
=================[==========] Running 9 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 9 tests from Switch
[ RUN      ] Switch.GetConfig
[       OK ] Switch.GetConfig (13 ms)
[ RUN      ] Switch.ConfigOptions
[       OK ] Switch.ConfigOptions (3 ms)
[ RUN      ] Switch.GetP4Objects
[       OK ] Switch.GetP4Objects (14 ms)
[ RUN      ] Switch.SerializeState1
[       OK ] Switch.SerializeState1 (7 ms)
[ RUN      ] Switch.SerializeState2
Traceback (most recent call last):File "../tools/runtime_CLI.py", line 30, in <module>import bmpy_utils as utilsFile "/home/wasdns/bmv2/tools/bmpy_utils.py", line 26, in <module>from thrift import Thrift
ImportError: No module named thrift
lt-test_switch: utils.cpp:55: CLIWrapperImp::~CLIWrapperImp(): Assertion `pclose(CLI_f) == 0' failed.
Thrift server was started

应该是thrift的问题,该问题还在解决中。

2016/12/17

P4 前端编译器p4c-bm、后端编译器bmv2命令安装 make error问题相关推荐

  1. 前端和后端开发人员比例_前端开发人员vs后端开发人员–实践中的定义和含义

    前端和后端开发人员比例 Websites and applications are complex! Buttons and images are just the tip of the iceber ...

  2. Vue:前端体系与前后端分离

    Vue:前端体系与前后端分离 概述 介绍 ​ Vue(读音/viu/,类似于 view)是一套用于构建用户界面的渐进式框架,发布干 2014 年 2 月. 与其它大型框架不同的是,Vue 被设计为可以 ...

  3. Vue:前端体系、前后端分离

    1.概述 Vue (读音/vju/, 类似于view)是一套用于构建用户界面的渐进式框架,发布于2014年2月.与其它大型框架不同的是,Vue 被设计为可以自底向上逐层应用.Vue的核心库只关注视图层 ...

  4. vue,狂神,狂神和飞哥,前端一直在抄袭后端

    Vue.js (vuejs.org) Bootstrap可视化布局系统 (bootcss.com) MyBatis入门学习-KuangStudy-文章 一 前端体系 此课程的重点 前端的话,页面我不会 ...

  5. 大前端–Vue前端体系、前后端分离

    大前端–Vue前端体系.前后端分离 前言 Soc:关注点分离原则 HTML+CSS+JS(视图):给用户看,刷新后台给的数据 网络通信:axios 页面跳转:vue-router 状态管理:vuex ...

  6. 【Linux-GNU编译器套件(gcc/g++/gfortran)离线编译安装】

    文章目录 Linux-centos7.9系统GNU编译器套件(gcc/g++/gfortran)离线编译安装 一.★GNU编译器套件定义 二.★GNU-GCC编译环境说明 三.★GNU-GCC编译安装 ...

  7. 华为鸿蒙编译器下载,华为方舟编译器

    华为方舟编译器是最新上线的华为编译系统,用户可以在这里编译源代码,他功能强大,多种芯片联合尽心编译的运行和设一统一的平台,华为方舟编译器让用户不在只能选择安卓和苹果系统,华为鸿蒙系统的推出让用户有更多 ...

  8. python后端开发框架加密_Flask框架实现的前端RSA加密与后端Python解密功能详解

    本文实例讲述了Flask框架实现的前端RSA加密与后端Python解密功能.分享给大家供大家参考,具体如下: 前言 在使用 Flask 开发用户登录API的时候,我之前都是明文传输 username ...

  9. 写给刚入门的前端工程师的前后端交互指南

    转自原文 写给刚入门的前端工程师的前后端交互指南 作为刚接触前端的不久的童鞋,大家都会兴奋于CSS和JS所带来漂亮界面,然而,前端工程师除了UI重构外,还有非常重要的职责在正确的区域渲染出服务端的数据 ...

最新文章

  1. windows2008 sp2 x64安装 ocs 2007 r2 笔记
  2. 用Vue.js开发一个电影App的前端界面
  3. python元组求和_Python 列表和元组 - 学习笔记(持续更新)
  4. MySQL二进制版本的安装及卸载
  5. 最老程序员创业札记:全文检索、数据挖掘、推荐引擎应用19
  6. Android Support兼容包详解
  7. 斑马Revit:“BIM等级考试证书”究竟要不要考?
  8. java 度分秒转换为度_andriod Java中度转度分秒
  9. 毕业设计的开题报告怎么写?
  10. python 两点曲线_ECC椭圆曲线加密算法:ECDH 和 ECDSA
  11. 在excel中创建日历
  12. 在wine里面播放视频和音乐之WMP
  13. 免校准的电量计量芯片_技术 | 免校准电能计量芯片,让家电智能化更简单
  14. Service Mesh中的通用数据平面API设计
  15. 推荐一款工作学习中十分好用的插件--uTools
  16. 浅谈游戏《Dead Cells死亡细胞》
  17. 孙悟空无姓无名的时候,阎王生死簿是怎么写的呢?
  18. 使用Electron构建跨平台文档扫描应用程序
  19. 数据库(66期第三天)
  20. (附源码)计算机毕业设计SSM基于技术的高校学生勤工俭学管理系统的设计与开发

热门文章

  1. 选择控件— UI组件系列
  2. 小程序卡片叠层切换卡片_现在,卡片和清单在哪里?
  3. 【建议收藏】面试官贼喜欢问的 32+ vue 修饰符,你掌握几种啦?
  4. 我在工作中是如何使用Git的
  5. 《CSS揭秘》读书笔记
  6. mysql数据库表的管理(增删改)
  7. 【转载】【面试题】你是一个测试工程师,如何保证软件质量?
  8. keepalived实现nginx的高可用(双主模型)
  9. js 错误/异常处理
  10. 转软件开发过程中的各种文档