ubuntu thrift 0.9.3编译安装

安装依赖

?
1
2
3
4
5
6
apt-get install automake
apt-get install libssl-dev
apt-get install byacc
apt-get install bison
apt-get install flex
apt-get install libevent-dev

生成编译文件

?
1
2
3
4
5
6
7
8
9
cd thrift
./bootstrap.sh
configure.ac: 84 : installing './compile'
configure.ac: 88 : installing './config.guess'
configure.ac: 88 : installing './config.sub'
configure.ac: 27 : installing './install-sh'
configure.ac: 27 : installing './missing'
compiler/cpp/Makefile.am: installing './depcomp'
configure.ac: installing './ylwrap'

编译前配置,禁用java和python, 安装目录设为/usr/lib,而不是默认的/usr/local/lib

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
./configure --libdir=/usr/lib --without-java --without-python
--without-c_glib
thrift 0.9 . 3
 
Building C++ Library ......... : yes
Building C (GLib) Library .... : no
Building Java Library ........ : no
Building C# Library .......... : no
Building Python Library ...... : no
Building Ruby Library ........ : no
Building Haxe Library ........ : no
Building Haskell Library ..... : no
Building Perl Library ........ : no
Building PHP Library ......... : no
Building Erlang Library ...... : no
Building Go Library .......... : no
Building D Library ........... : no
Building NodeJS Library ...... : no
Building Lua Library ......... : no
 
C++ Library:
    Build TZlibTransport ...... : yes
    Build TNonblockingServer .. : yes
    Build TQTcpServer (Qt4) .... : no
    Build TQTcpServer (Qt5) .... : no
 
If something is missing that you think should be present,
please skim the output of configure to find the missing
component.  Details are present in config.log.

编译

?
1
make

 运行测试程序

测试

?
1
make check

注意,v0.9.3的make check有个bug, 这里是对应的jira issue, 报错信息是

?
1
2
An error message from getaddrinfo on the console is expected:
Thrift: Mon Dec 14 12 : 19 : 09 2015 TServerSocket::listen() BIND 9090

 安装

sudo make install

注意:

  • $thrift-git-project 是thrift gi项目所在目录库文件安装在/usr/lib目录下头文件安装在/usr/local/include/thrift目录下
    ?
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    Making install in compiler/cpp
    make[ 1 ]: Entering directory '$thrift-git-project/compiler/cpp'
    make  install-am
    make[ 2 ]: Entering directory '$thrift-git-project/compiler/cpp'
    make[ 3 ]: Entering directory '$thrift-git-project/compiler/cpp'
      /bin/mkdir -p '/usr/local/bin'
       /bin/bash ../../libtool   --mode=install /usr/bin/install -c thrift '/usr/local/bin'
    libtool: install: /usr/bin/install -c thrift /usr/local/bin/thrift
    make[ 3 ]: Nothing to be done for 'install-data-am' .
    make[ 3 ]: Leaving directory '$thrift-git-project/compiler/cpp'
    make[ 2 ]: Leaving directory '$thrift-git-project/compiler/cpp'
    make[ 1 ]: Leaving directory '$thrift-git-project/compiler/cpp'
    Making install in lib
    make[ 1 ]: Entering directory '$thrift-git-project/lib'
    Making install in cpp
    make[ 2 ]: Entering directory '$thrift-git-project/lib/cpp'
    Making install in .
    make[ 3 ]: Entering directory '$thrift-git-project/lib/cpp'
    make[ 4 ]: Entering directory '$thrift-git-project/lib/cpp'
      /bin/mkdir -p '/usr/lib'
      /bin/bash ../../libtool   --mode=install /usr/bin/install -c   libthrift.la libthriftnb.la libthriftz.la '/usr/lib'
    libtool: install: /usr/bin/install -c .libs/libthrift- 0.9 . 3 .so /usr/lib/libthrift- 0.9 . 3 .so
    libtool: install: (cd /usr/lib && { ln -s -f libthrift- 0.9 . 3 .so libthrift.so || { rm -f libthrift.so && ln -s libthrift- 0.9 . 3 .so libthrift.so; }; })
    libtool: install: /usr/bin/install -c .libs/libthrift.lai /usr/lib/libthrift.la
    libtool: install: /usr/bin/install -c .libs/libthriftnb- 0.9 . 3 .so /usr/lib/libthriftnb- 0.9 . 3 .so
    libtool: install: (cd /usr/lib && { ln -s -f libthriftnb- 0.9 . 3 .so libthriftnb.so || { rm -f libthriftnb.so && ln -s libthriftnb- 0.9 . 3 .so libthriftnb.so; }; })
    libtool: install: /usr/bin/install -c .libs/libthriftnb.lai /usr/lib/libthriftnb.la
    libtool: install: /usr/bin/install -c .libs/libthriftz- 0.9 . 3 .so /usr/lib/libthriftz- 0.9 . 3 .so
    libtool: install: (cd /usr/lib && { ln -s -f libthriftz- 0.9 . 3 .so libthriftz.so || { rm -f libthriftz.so && ln -s libthriftz- 0.9 . 3 .so libthriftz.so; }; })
    libtool: install: /usr/bin/install -c .libs/libthriftz.lai /usr/lib/libthriftz.la
    libtool: install: /usr/bin/install -c .libs/libthrift.a /usr/lib/libthrift.a
    libtool: install: chmod 644 /usr/lib/libthrift.a
    libtool: install: ranlib /usr/lib/libthrift.a
    libtool: install: /usr/bin/install -c .libs/libthriftnb.a /usr/lib/libthriftnb.a
    libtool: install: chmod 644 /usr/lib/libthriftnb.a
    libtool: install: ranlib /usr/lib/libthriftnb.a
    libtool: install: /usr/bin/install -c .libs/libthriftz.a /usr/lib/libthriftz.a
    libtool: install: chmod 644 /usr/lib/libthriftz.a
    libtool: install: ranlib /usr/lib/libthriftz.a
    libtool: finish: PATH= "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/sbin" ldconfig -n /usr/lib
    ----------------------------------------------------------------------
    Libraries have been installed in:
        /usr/lib
     
    If you ever happen to want to link against installed libraries
    in a given directory, LIBDIR, you must either use libtool, and
    specify the full pathname of the library, or use the `-LLIBDIR'
    flag during linking and do at least one of the following:
        - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
          during execution
        - add LIBDIR to the `LD_RUN_PATH' environment variable
          during linking
        - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
        - have your system administrator add LIBDIR to `/etc/ld.so.conf'
     
    See any operating system documentation about shared libraries for
    more information, such as the ld( 1 ) and ld.so( 8 ) manual pages.
    ----------------------------------------------------------------------
      /bin/mkdir -p '/usr/local/include/thrift/async'
      /usr/bin/install -c -m 644 src/thrift/async/TAsyncChannel.h src/thrift/async/TAsyncDispatchProcessor.h src/thrift/async/TAsyncProcessor.h src/thrift/async/TAsyncBufferProcessor.h src/thrift/async/TAsyncProtocolProcessor.h src/thrift/async/TConcurrentClientSyncInfo.h src/thrift/async/TEvhttpClientChannel.h src/thrift/async/TEvhttpServer.h '/usr/local/include/thrift/async'
      /bin/mkdir -p '/usr/local/include/thrift/concurrency'
      /usr/bin/install -c -m 644 src/thrift/concurrency/BoostThreadFactory.h src/thrift/concurrency/Exception.h src/thrift/concurrency/Mutex.h src/thrift/concurrency/Monitor.h src/thrift/concurrency/PlatformThreadFactory.h src/thrift/concurrency/PosixThreadFactory.h src/thrift/concurrency/StdMonitor.cpp src/thrift/concurrency/StdMutex.cpp src/thrift/concurrency/StdThreadFactory.cpp src/thrift/concurrency/StdThreadFactory.h src/thrift/concurrency/Thread.h src/thrift/concurrency/ThreadManager.h src/thrift/concurrency/TimerManager.h src/thrift/concurrency/FunctionRunner.h src/thrift/concurrency/Util.h '/usr/local/include/thrift/concurrency'
      /bin/mkdir -p '/usr/local/include/thrift/processor'
      /usr/bin/install -c -m 644 src/thrift/processor/PeekProcessor.h src/thrift/processor/StatsProcessor.h src/thrift/processor/TMultiplexedProcessor.h '/usr/local/include/thrift/processor'
      /bin/mkdir -p '/usr/local/include/thrift/protocol'
      /usr/bin/install -c -m 644 src/thrift/protocol/TBinaryProtocol.h src/thrift/protocol/TBinaryProtocol.tcc src/thrift/protocol/TCompactProtocol.h src/thrift/protocol/TCompactProtocol.tcc src/thrift/protocol/TDebugProtocol.h src/thrift/protocol/TBase64Utils.h src/thrift/protocol/TJSONProtocol.h src/thrift/protocol/TMultiplexedProtocol.h src/thrift/protocol/TProtocolDecorator.h src/thrift/protocol/TProtocolTap.h src/thrift/protocol/TProtocolException.h src/thrift/protocol/TVirtualProtocol.h src/thrift/protocol/TProtocol.h '/usr/local/include/thrift/protocol'
      /bin/mkdir -p '/usr/local/include/thrift/qt'
      /usr/bin/install -c -m 644 src/thrift/qt/TQIODeviceTransport.h src/thrift/qt/TQTcpServer.h '/usr/local/include/thrift/qt'
      /bin/mkdir -p '/usr/local/include/thrift/server'
      /usr/bin/install -c -m 644 src/thrift/server/TConnectedClient.h src/thrift/server/TServer.h src/thrift/server/TServerFramework.h src/thrift/server/TSimpleServer.h src/thrift/server/TThreadPoolServer.h src/thrift/server/TThreadedServer.h src/thrift/server/TNonblockingServer.h '/usr/local/include/thrift/server'
      /bin/mkdir -p '/usr/local/include/thrift'
      /usr/bin/install -c -m 644 ../../config.h src/thrift/thrift-config.h src/thrift/TDispatchProcessor.h src/thrift/Thrift.h src/thrift/TOutput.h src/thrift/TProcessor.h src/thrift/TApplicationException.h src/thrift/TLogging.h src/thrift/cxxfunctional.h src/thrift/TToString.h '/usr/local/include/thrift'
      /bin/mkdir -p '/usr/local/include/thrift/transport'
      /usr/bin/install -c -m 644 src/thrift/transport/PlatformSocket.h src/thrift/transport/TFDTransport.h src/thrift/transport/TFileTransport.h src/thrift/transport/TSimpleFileTransport.h src/thrift/transport/TServerSocket.h src/thrift/transport/TSSLServerSocket.h src/thrift/transport/TServerTransport.h src/thrift/transport/THttpTransport.h src/thrift/transport/THttpClient.h src/thrift/transport/THttpServer.h src/thrift/transport/TSocket.h src/thrift/transport/TPipe.h src/thrift/transport/TPipeServer.h src/thrift/transport/TSSLSocket.h src/thrift/transport/TSocketPool.h src/thrift/transport/TVirtualTransport.h src/thrift/transport/TTransport.h src/thrift/transport/TTransportException.h src/thrift/transport/TTransportUtils.h src/thrift/transport/TBufferTransports.h src/thrift/transport/TShortReadTransport.h src/thrift/transport/TZlibTransport.h '/usr/local/include/thrift/transport'
      /bin/mkdir -p '/usr/lib/pkgconfig'
      /usr/bin/install -c -m 644 thrift.pc thrift-nb.pc thrift-z.pc '/usr/lib/pkgconfig'
    make[ 4 ]: Leaving directory '$thrift-git-project/lib/cpp'
    make[ 3 ]: Leaving directory '$thrift-git-project/lib/cpp'
    Making install in test
    make[ 3 ]: Entering directory '$thrift-git-project/lib/cpp/test'
    make  install-am
    make[ 4 ]: Entering directory '$thrift-git-project/lib/cpp/test'
    make[ 5 ]: Entering directory '$thrift-git-project/lib/cpp/test'
    make[ 5 ]: Nothing to be done for 'install-exec-am' .
    make[ 5 ]: Nothing to be done for 'install-data-am' .
    make[ 5 ]: Leaving directory '$thrift-git-project/lib/cpp/test'
    make[ 4 ]: Leaving directory '$thrift-git-project/lib/cpp/test'
    make[ 3 ]: Leaving directory '$thrift-git-project/lib/cpp/test'
    make[ 2 ]: Leaving directory '$thrift-git-project/lib/cpp'
    make[ 2 ]: Entering directory '$thrift-git-project/lib'
    make[ 3 ]: Entering directory '$thrift-git-project/lib'
    make[ 3 ]: Nothing to be done for 'install-exec-am' .
    make[ 3 ]: Nothing to be done for 'install-data-am' .
    make[ 3 ]: Leaving directory '$thrift-git-project/lib'
    make[ 2 ]: Leaving directory '$thrift-git-project/lib'
    make[ 1 ]: Leaving directory '$thrift-git-project/lib'
    Making install in test
    make[ 1 ]: Entering directory '$thrift-git-project/test'
    Making install in cpp
    make[ 2 ]: Entering directory '$thrift-git-project/test/cpp'
    make  install-am
    make[ 3 ]: Entering directory '$thrift-git-project/test/cpp'
    make[ 4 ]: Entering directory '$thrift-git-project/test/cpp'
    make[ 4 ]: Nothing to be done for 'install-exec-am' .
    make[ 4 ]: Nothing to be done for 'install-data-am' .
    make[ 4 ]: Leaving directory '$thrift-git-project/test/cpp'
    make[ 3 ]: Leaving directory '$thrift-git-project/test/cpp'
    make[ 2 ]: Leaving directory '$thrift-git-project/test/cpp'
    make[ 2 ]: Entering directory '$thrift-git-project/test'
    make[ 3 ]: Entering directory '$thrift-git-project/test'
    make[ 3 ]: Nothing to be done for 'install-exec-am' .
    make[ 3 ]: Nothing to be done for 'install-data-am' .
    make[ 3 ]: Leaving directory '$thrift-git-project/test'
    make[ 2 ]: Leaving directory '$thrift-git-project/test'
    make[ 1 ]: Leaving directory '$thrift-git-project/test'
    Making install in tutorial
    make[ 1 ]: Entering directory '$thrift-git-project/tutorial'
    Making install in cpp
    make[ 2 ]: Entering directory '$thrift-git-project/tutorial/cpp'
    make  install-am
    make[ 3 ]: Entering directory '$thrift-git-project/tutorial/cpp'
    make[ 4 ]: Entering directory '$thrift-git-project/tutorial/cpp'
    make[ 4 ]: Nothing to be done for 'install-exec-am' .
    make[ 4 ]: Nothing to be done for 'install-data-am' .
    make[ 4 ]: Leaving directory '$thrift-git-project/tutorial/cpp'
    make[ 3 ]: Leaving directory '$thrift-git-project/tutorial/cpp'
    make[ 2 ]: Leaving directory '$thrift-git-project/tutorial/cpp'
    make[ 2 ]: Entering directory '$thrift-git-project/tutorial'
    ../compiler/cpp/thrift --gen html -r ../tutorial/tutorial.thrift
    make[ 3 ]: Entering directory '$thrift-git-project/tutorial'
    make[ 3 ]: Nothing to be done for 'install-exec-am' .
    make[ 3 ]: Nothing to be done for 'install-data-am' .
    make[ 3 ]: Leaving directory '$thrift-git-project/tutorial'
    make[ 2 ]: Leaving directory '$thrift-git-project/tutorial'
    make[ 1 ]: Leaving directory '$thrift-git-project/tutorial'
    make[ 1 ]: Entering directory '$thrift-git-project'
    make[ 2 ]: Entering directory '$thrift-git-project'
    make[ 2 ]: Nothing to be done for 'install-exec-am' .
    make[ 2 ]: Nothing to be done for 'install-data-am' .
    make[ 2 ]: Leaving directory '$thrift-git-project'
    make[ 1 ]: Leaving directory '$thrift-git-project'
<think>好的,用户现在想要在Ubuntu 18.04下搭建P4编程语言环境,并询问各个软件的推荐版本。首先,我需要回忆P4环境所需的组件以及它们的版本兼容性。因为P4是一个相对专业的领域,可能用户是网络编程的研究人员或学生,他们需要配置特定的工具链来进行网络协议或数据平面的编程。 首先,P4环境通常包括以下几个部分:P4编译器(如p4c)、BMv2软件交换机、Mininet网络模拟器、PI(Protocol Independence)库、以及一些依赖如Thrift、nanomsg等。此外,可能还需要考虑内核模块或驱动,比如Linux的headers,以及Python的版本,因为很多工具是用Python编写的。 接下来,Ubuntu 18.04本身的软件仓库可能不包含最新版本的这些工具,所以用户可能需要从源码编译安装。这时候版本兼容性就非常重要了,因为不同版本的组件之间可能存在接口变化,导致编译或运行时错误。 对于P4编译器p4c,需要确定哪个版本与Ubuntu 18.04兼容。我记得p4c在2019年左右有较大的更新,可能v1.2.4是一个比较稳定的版本,适合Ubuntu 18.04。而BMv2作为行为模型,其版本也需要与p4c匹配,比如1.15.0可能是一个合适的选择。Mininet的版本可能不是最关键,但2.3.0是较旧的稳定版,适合在Ubuntu 18.04上运行。 PI库和Thrift的版本也需要匹配。例如,Thrift 0.13.0可能是一个安全的选择,因为较新版本可能会有兼容性问题。nanomsg和libjudy同样需要特定版本以确保依赖关系正确。 另外,用户可能需要Python 3.6,因为Ubuntu 18.04默认可能带有Python 3.6,而某些工具可能尚未适配更高版本的Python。安装pip3和相关的Python包如ptf、scapy也是必要的步骤。 在安装过程中,用户可能会遇到依赖项缺失的问题,比如缺少automake、libtool等构建工具,所以需要提前安装这些依赖。此外,网络问题可能导致从GitHub克隆仓库失败,所以可能需要配置代理或使用镜像源。 用户可能的深层需求是顺利搭建环境,避免因版本不匹配导致的反复调试。因此,明确的版本推荐和具体的安装步骤是关键。同时,用户可能需要后续的验证步骤,比如运行示例程序,确保所有组件正确工作。 最后,需要提醒用户注意系统的更新和虚拟环境的考虑,比如使用虚拟机或容器来隔离环境,避免影响宿主系统。如果用户遇到问题,建议查阅官方文档或社区支持,因为P4生态的版本更新较快,可能存在变化。</think>在 Ubuntu 18.04 下搭建 P4 编程环境时,版本兼容性非常重要。以下是推荐的软件版本及安装步骤,确保环境稳定和功能完整: --- ### **1. 推荐版本清单** | **软件/工具** | **推荐版本** | **备注** | |----------------------|--------------------|------------------------------------| | **操作系统** | Ubuntu 18.04 LTS | 长期支持版,兼容性最佳 | | **P4 编译器 (p4c)** | `v1.2.4` | 稳定版本,支持 P4_16 和 P4_14 | | **BMv2 软件交换机** | `1.15.0` | 行为模型参考实现 | | **Mininet** | `2.3.0` | 网络模拟工具 | | **PI (Protocol Independence)** | `v1.3.0` | P4 Runtime 协议库 | | **Thrift** | `0.13.0` | RPC 框架(BMv2 和 PI 依赖) | | **nanomsg** | `1.1.5` | 消息传递库(BMv2 依赖) | | **Python** | `3.6` | Ubuntu 18.04 默认 Python3 版本 | | **g++** | `7.5.0` | 支持 C++11/14 的编译器 | --- ### **2. 安装步骤** #### **步骤 1:安装系统依赖** ```bash sudo apt update sudo apt install -y \ automake cmake git curl build-essential \ libtool pkg-config libboost-dev libboost-system-dev \ libboost-thread-dev libevent-dev libjudy-dev \ libgmp-dev libpcap-dev libssl-dev libnanomsg-dev \ python3 python3-pip python3-setuptools \ tcpdump wireshark ``` #### **步骤 2:安装 Thrift 0.13.0** ```bash wget https://archive.apache.org/dist/thrift/0.13.0/thrift-0.13.0.tar.gz tar -xzf thrift-0.13.0.tar.gz cd thrift-0.13.0 ./configure --without-ruby --without-java --without-python make -j$(nproc) sudo make install ``` #### **步骤 3安装 PI (Protocol Independence)** ```bash git clone --branch v1.3.0 https://github.com/p4lang/PI cd PI git submodule update --init --recursive ./autogen.sh ./configure --with-proto make -j$(nproc) sudo make install ``` #### **步骤 4:安装 BMv2 软件交换机** ```bash git clone --branch 1.15.0 https://github.com/p4lang/behavioral-model cd behavioral-model ./install_deps.sh # 安装依赖项 ./autogen.sh ./configure --enable-debugger --with-pi make -j$(nproc) sudo make install ``` #### **步骤 5:安装 P4 编译器 (p4c)** ```bash git clone --branch v1.2.4 https://github.com/p4lang/p4c cd p4c mkdir build && cd build cmake .. -DENABLE_BMV2=ON make -j$(nproc) sudo make install ``` #### **步骤 6:安装 Mininet** ```bash git clone --branch 2.3.0 https://github.com/mininet/mininet cd mininet sudo PYTHON=python3 ./util/install.sh -n ``` #### **步骤 7:验证安装** ```bash # 测试 BMv2 simple_switch --version # 应输出 1.15.0 # 测试 P4 编译器 p4c --version # 应输出 1.2.4 # 测试 Mininet sudo mn --version # 应输出 2.3.0 ``` --- ### **3. 常见问题解决** - **问题 1:Thrift 版本冲突** 确保卸载旧版本 Thrift,或使用 `--prefix=/usr/local` 安装到独立路径。 - **问题 2:Python 依赖缺失** 安装 Python 包: ```bash pip3 install scapy==2.4.5 ptf==0.9.3 ``` - **问题 3:动态库路径错误** 添加库路径到环境变量: ```bash echo &#39;export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH&#39; >> ~/.bashrc source ~/.bashrc ``` --- ### **4. 推荐使用虚拟机/容器** 为避免污染系统环境,建议在 **VirtualBox** 或 **Docker** 中搭建开发环境。例如,使用官方 P4 镜像: ```bash docker pull p4lang/p4c ``` --- ### **总结** - 版本匹配是关键,避免混合使用不同分支的代码。 - 推荐按顺序安装依赖项,确保编译过程顺利。 - 测试时优先运行官方示例(如 [p4lang/tutorials](https://github.com/p4lang/tutorials))。 遇到问题可参考 [P4 官方文档](https://p4.org/) 或 GitHub Issues。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值