You can use a Pulsar C++ client to create Pulsar producers, consumers, and readers in C++. All the methods in Pulsar C++ clients are thread-safe.
The new version of the Pulsar C++ client starts from 3.0.0 and has been no longer consistent with Pulsar since 2.10.x. For the latest releases, see the Download page.
Take the 3.0.0 release for example, there are following subdirectories:
These Linux packages above all contain the C++ headers installed under /usr/include
and the following libraries installed under /usr/lib
:
Here is an example to link these libraries for a C++ source file named main.cc
:
# Link to libpulsar.so g++ -std=c++11 main.cc -lpulsar # Link to libpulsarwithdeps.a g++ -std=c++11 main.cc /usr/lib/libpulsarwithdeps.a -lpthread -ldl # Link to libpulsar.a g++ -std=c++11 main.cc /usr/lib/libpulsar.a \ -lprotobuf -lcurl -lssl -lcrypto -lz -lzstd -lsnappy -lpthread -ldl
:::caution
Linking to libpulsar.a
can be difficult for beginners because the 3rd party dependencies must be compatible. For example, the protobuf version must be 3.20.0 or higher for Pulsar C++ client 3.0.0. It's better to link to libpulsarwithdeps.a
instead.
:::
:::danger
Before 3.0.0, there was a libpulsarnossl.so
, which is removed now.
:::