tree: 88c2e22cb4662b7a9526f01c45e02fd63206bb4a [path history] [tgz]
  1. build-support/
  2. cmake_modules/
  3. docker/
  4. docs/
  5. examples/
  6. homebrew/
  7. include/
  8. lib/
  9. perf/
  10. pkg/
  11. python/
  12. test-conf/
  13. tests/
  14. wireshark/
  15. .clang-format
  16. .gitignore
  17. CMakeLists.txt
  18. docker-build.sh
  19. docker-format.sh
  20. docker-tests.sh
  21. Doxyfile
  22. eclipse-formatter.xml
  23. log4cxx.conf
  24. pulsar-test-service-start.sh
  25. pulsar-test-service-stop.sh
  26. README.md
  27. run-unit-tests.sh
  28. travis-build.sh
pulsar-client-cpp/README.md

Pulsar C++ client library

Examples for using the API to publish and consume messages can be found on https://github.com/apache/pulsar/tree/master/pulsar-client-cpp/examples

Requirements

Platforms

Pulsar C++ Client Library has been tested on:

  • Linux
  • Mac OS X

Compilation

Compile within a Docker container

You can compile the C++ client library within a Docker container that already contains all the required dependencies.

./docker-build.sh

Run unit tests:

./docker-tests.sh

Compile on Ubuntu Server 16.04

Install all dependencies:

apt-get install -y g++ cmake libssl-dev libcurl4-openssl-dev liblog4cxx-dev \
                libprotobuf-dev libboost-all-dev  libgtest-dev google-mock \
                libjsoncpp-dev libxml2-utils protobuf-compiler python-setuptools

Compile and install Google Test:

cd /usr/src/gtest
sudo cmake .
sudo make
sudo cp *.a /usr/lib

Compile and install Google Mock:

cd /usr/src/gmock
sudo cmake .
sudo make
sudo cp *.a /usr/lib

Compile Pulsar client library:

cd pulsar/pulsar-client-cpp
cmake .
make

Checks

Client library will be placed in
lib/libpulsar.so
lib/libpulsar.a
Tools will be placed in
perf/perfProducer
perf/perfConsumer

Compile on Mac OS X

Install all dependencies:

# For openSSL
brew install openssl
export OPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include/
export OPENSSL_ROOT_DIR=/usr/local/opt/openssl/

# For Protobuf
brew install protobuf boost boost-python log4cxx jsoncpp
// If you are using python3, you need to install boost-python3

# For gtest
cd $HOME
git clone https://github.com/google/googletest.git
cd googletest
cmake .
make install
# Refer gtest documentation in case you get stuck somewhere

Compile Pulsar client library:

export PULSAR_PATH=<Path where you cloned pulsar repo>
cd ${PULSAR_PATH}/pulsar-client-cpp/
cmake .
make

Checks

Client library will be placed in
${PULSAR_PATH}/pulsar-client-cpp/lib/libpulsar.dylib
${PULSAR_PATH}/pulsar-client-cpp/lib/libpulsar.a
Tools will be placed in:
${PULSAR_PATH}/pulsar-client-cpp/perf/perfProducer
${PULSAR_PATH}/pulsar-client-cpp/perf/perfConsumer

Compile on Windows

Install all dependencies:

Clone and build all dependencies from source if a binary distro can't be found.

If you want to build and run the tests, then also install

Compile Pulsar client library:

#If all dependencies are in your path, all that is necessary is
${PULSAR_PATH}/pulsar-client-cpp/cmake .

#if all dependencies are not in your path, then passing in a PROTOC_PATH and CMAKE_PREFIX_PATH is necessary
${PULSAR_PATH}/pulsar-client-cpp/cmake -DPROTOC_PATH=C:/protobuf/bin/protoc -DCMAKE_PREFIX_PATH="C:/boost;C:/openssl;C:/zlib;C:/curl;C:/protobuf;C:/googletest;C:/dlfcn-win32" .

#This will generate pulsar-cpp.sln. Open this in Visual Studio and build the desired configurations.

Tests

# Source code
${PULSAR_PATH}/pulsar-client-cpp/tests/

# Execution
# Start standalone broker
${PULSAR_PATH}/pulsar-test-service-start.sh

# Run the tests
${PULSAR_PATH}/pulsar-client-cpp/tests/main

# When no longer needed, stop standalone broker
${PULSAR_PATH}/pulsar-test-service-stop.sh

Requirements for Contributors

We welcome contributions from the open source community, kindly make sure your changes are backward compatible with gcc-4.4.7 and Boost 1.41.