Created
October 20, 2020 14:44
-
-
Save BewareMyPower/82d8ca2dc4c44a43cde86c2d64895318 to your computer and use it in GitHub Desktop.
安装 libpulsar.so 到系统路径(Ubuntu/Debian 版本)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # 适用于 Ubuntu/Debian 系统的 pulsar-client-cpp 编译脚本 | |
| set -e | |
| # 0. 安装基本工具 | |
| apt install -y git wget | |
| # 1. 安装编译工具,在 Debian 4.9.210-1 (2020-01-20) 上面是 g++ 6.3 和 cmake 3.7 | |
| # 最低要求:g++ >= 4.8.5,cmake >= 3.4 | |
| apt install -y gcc g++ cmake | |
| # 2. 安装依赖 | |
| apt install -y libssl-dev libcurl4-openssl-dev zlib1g-dev libboost-all-dev | |
| ################################################################################################### | |
| # 以下部分是 Linux 平台都适用的,前面的部分对于 CentOS/RedHat 而言需要找到对应的依赖名字 | |
| ################################################################################################### | |
| # protobuf-2.6 是手动源码编译(似乎也可以从源安装?),会安装以下文件: | |
| # /usr/local/bin/protoc 需要加入 PATH 环境变量 | |
| # /usr/local/lib/libprotobuf* 相关库文件,需要加入 LD_LIBRARY_PATH 环境变量 | |
| # 如果要安装到其他目录,可以在 configure 时指定 --prefix=/your/path | |
| wget https://github.com/protocolbuffers/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.gz | |
| tar zxf protobuf-2.6.1.tar.gz | |
| cd protobuf-2.6.1 | |
| ./configure | |
| make | |
| make install | |
| cd - | |
| # 注意:这一步是引入 protobuf 动态库,在之后也需要导入到环境变量中 | |
| export PATH=/usr/local/bin:$PATH | |
| export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH | |
| # 3. 克隆 pulsar 项目,源码编译 | |
| git clone https://github.com/apache/pulsar.git | |
| pushd pulsar/pulsar-client-cpp | |
| mkdir _builds | |
| cd _builds | |
| cmake .. \ | |
| -DBUILD_PYTHON_WRAPPER=OFF \ | |
| -DBUILD_TESTS=OFF | |
| # 这里建议开多线程编译,比如 -j4 选项进行 4 线程编译,否则会很慢 | |
| make | |
| # 如果要安装到其他目录,可以在 cmake 时指定 -DCMAKE_INSTALL_PATH=/your/path | |
| make install |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment