forked from apache/pulsar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved instruction for getting started with C++ client lib (apache#…
…1975) ### Motivation Documentation for C++ library was mixed with instructions on how to build the library and how to use it. ### Modifications * Split the C++ client page in 2 parts, one for building and one for using * Added instructions to build RPM, which is much easier than build directly (since it builds in Docker with all dependencies installed).
- Loading branch information
Showing
3 changed files
with
163 additions
and
87 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
--- | ||
title: Building Pulsar C++ client | ||
tags: [client, cpp] | ||
--- | ||
|
||
<!-- | ||
Licensed to the Apache Software Foundation (ASF) under one | ||
or more contributor license agreements. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. The ASF licenses this file | ||
to you under the Apache License, Version 2.0 (the | ||
"License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, | ||
software distributed under the License is distributed on an | ||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations | ||
under the License. | ||
--> | ||
|
||
## Supported platforms | ||
|
||
The Pulsar C++ client has been successfully tested on **MacOS** and **Linux**. | ||
|
||
## System requirements | ||
|
||
You need to have the following installed to use the C++ client: | ||
|
||
* [CMake](https://cmake.org/) | ||
* [Boost](http://www.boost.org/) | ||
* [Protocol Buffers](https://developers.google.com/protocol-buffers/) 2.6 | ||
* [Log4CXX](https://logging.apache.org/log4cxx) | ||
* [libcurl](https://curl.haxx.se/libcurl/) | ||
* [Google Test](https://github.com/google/googletest) | ||
* [JsonCpp](https://github.com/open-source-parsers/jsoncpp) | ||
|
||
## Compilation | ||
|
||
There are separate compilation instructions for [MacOS](#macos) and [Linux](#linux). For both systems, start by cloning the Pulsar repository: | ||
|
||
```shell | ||
$ git clone {{ site.pulsar_repo }} | ||
``` | ||
|
||
### Linux | ||
|
||
First, install all of the necessary dependencies: | ||
|
||
```shell | ||
$ apt-get install cmake libssl-dev libcurl4-openssl-dev liblog4cxx-dev \ | ||
libprotobuf-dev libboost-all-dev google-mock libgtest-dev libjsoncpp-dev | ||
``` | ||
|
||
Then compile and install [Google Test](https://github.com/google/googletest): | ||
|
||
```shell | ||
# libgtest-dev version is 1.18.0 or above | ||
$ cd /usr/src/googletest | ||
$ sudo cmake . | ||
$ sudo make | ||
$ sudo cp ./googlemock/libgmock.a ./googletest/libgtest.a /usr/lib/ | ||
|
||
# less than 1.18.0 | ||
$ cd /usr/src/gtest | ||
$ sudo cmake . | ||
$ sudo make | ||
$ sudo cp libgtest.a /usr/lib | ||
|
||
$ cd /usr/src/gmock | ||
$ sudo cmake . | ||
$ sudo make | ||
$ sudo cp libgmock.a /usr/lib | ||
``` | ||
|
||
Finally, compile the Pulsar client library for C++ inside the Pulsar repo: | ||
|
||
```shell | ||
$ cd pulsar-client-cpp | ||
$ cmake . | ||
$ make | ||
``` | ||
|
||
The resulting files, `libpulsar.so` and `libpulsar.a`, will be placed in the `lib` folder of the repo while two tools, `perfProducer` and `perfConsumer`, will be placed in the `perf` directory. | ||
|
||
### MacOS | ||
|
||
First, install all of the necessary dependencies: | ||
|
||
```shell | ||
# OpenSSL installation | ||
$ brew install openssl | ||
$ export OPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include/ | ||
$ export OPENSSL_ROOT_DIR=/usr/local/opt/openssl/ | ||
|
||
# Protocol Buffers installation | ||
$ brew tap homebrew/versions | ||
$ brew install protobuf260 | ||
$ brew install boost | ||
$ brew install log4cxx | ||
|
||
# Google Test installation | ||
$ git clone https://github.com/google/googletest.git | ||
$ cd googletest | ||
$ cmake . | ||
$ make install | ||
``` | ||
|
||
Then compile the Pulsar client library in the repo that you cloned: | ||
|
||
```shell | ||
$ cd pulsar-client-cpp | ||
$ cmake . | ||
$ make | ||
``` |