Building Pulsar C++ client

Supported platforms

The Pulsar C++ client has been successfully tested on MacOS and Linux.

系统要求

您需要安装以下内容才能使用C ++客户端:

编译

There are separate compilation instructions for MacOS and Linux. For both systems, start by cloning the Pulsar repository:

  1. $ git clone https://github.com/apache/pulsar

Linux

首先,安装所有必需的依赖项:

  1. $ apt-get install cmake libssl-dev libcurl4-openssl-dev liblog4cxx-dev \
  2. libprotobuf-dev protobuf-compiler libboost-all-dev google-mock libgtest-dev libjsoncpp-dev

Then compile and install Google Test:

  1. # libgtest-dev version is 1.18.0 or above
  2. $ cd /usr/src/googletest
  3. $ sudo cmake .
  4. $ sudo make
  5. $ sudo cp ./googlemock/libgmock.a ./googlemock/gtest/libgtest.a /usr/lib/
  6. # less than 1.18.0
  7. $ cd /usr/src/gtest
  8. $ sudo cmake .
  9. $ sudo make
  10. $ sudo cp libgtest.a /usr/lib
  11. $ cd /usr/src/gmock
  12. $ sudo cmake .
  13. $ sudo make
  14. $ sudo cp libgmock.a /usr/lib

最后,在Pulsar repo中编译C ++的Pulsar客户端库:

  1. $ cd pulsar-client-cpp
  2. $ cmake .
  3. $ make

首先,安装所有必需的依赖项:

MacOS

首先,安装所有必需的依赖项:

  1. # OpenSSL installation
  2. $ brew install openssl
  3. $ export OPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include/
  4. $ export OPENSSL_ROOT_DIR=/usr/local/opt/openssl/
  5. # Protocol Buffers installation
  6. $ brew tap homebrew/versions
  7. $ brew install protobuf260
  8. $ brew install boost
  9. $ brew install log4cxx
  10. # Google Test installation
  11. $ git clone https://github.com/google/googletest.git
  12. $ cd googletest
  13. $ cmake .
  14. $ make install

然后在您克隆的repo中编译Pulsar客户端库:

  1. $ cd pulsar-client-cpp
  2. $ cmake .
  3. $ make