Pulsar C++ client compilation failed on Ubuntu 18.04
See original GitHub issueDescribe the bug Could not get c++ client built on my Ubuntu 18.04 To Reproduce Follwed steps from official tutorial
git clone https://github.com/apache/pulsar
apt-get install cmake libssl-dev libcurl4-openssl-dev liblog4cxx-dev \ libprotobuf-dev protobuf-compiler libboost-all-dev google-mock libgtest-dev libjsoncpp-dev
# libgtest-dev version is 1.18.0 or above
cd /usr/src/googletest
sudo cmake .
sudo make
sudo cp ./googlemock/libgmock.a ./googlemock/gtest/libgtest.a /usr/lib/
cd /usr/src/gmock
sudo cmake .
sudo make
sudo cp libgmock.a /usr/lib
cd pulsar-client-cpp
cmake .
make
Could not make, it says: error: ‘class google::protobuf::FileDescriptorSet’ has no member named ‘ByteSizeLong’; did you mean ‘ByteSize’?
lib/CMakeFiles/PULSAR_OBJECT_LIB.dir/build.make:1605: recipe for target 'lib/CMakeFiles/PULSAR_OBJECT_LIB.dir/ProtobufNativeSchema.cc.o' failed
Error
Try to fix the error
As suggsted, changed ByteSizeLong
to ByteSize
in ./pulsar-client-cpp/lib/ProtobufNativeSchema.cc code, then got new error:
PaddingDemo.proto:25:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default. tests/CMakeFiles/main.dir/build.make:68: recipe for target 'generated/tests/PaddingDemo.pb.cc' failed
Desktop (please complete the following information):
- OS: [Ubuntu 18.04]
Additional context I guess it has to do with protobuf version, but could not find any more information. Thank you!
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
TL; DR the example code is wrong, we need to fix the doc. /cc @Anonymitaet
You should add a declaration before
createProducer
:It’s not a follow-up step. It’s a parallel step.
When you install a C++ SDK, it means following files need to be generated:
*.h
)*.so
on Linux) or a static library (*.a
on Linux).A
*.deb
file is a pre-built Debian C++ package. (Ubuntu is derived from Debian) i.e. theapt install ./apache-pulsar-client.deb
command will install the C++ headers and libraries to the target directory. Since the pre-built Debian C++ package doesn’t include a static library, you won’t see a*.a
file.However, if you have the source code of the C++ SDK, you can compile it by yourself, i.e. run
cmake
andmake
commands (or./configure
for C++ libraries that use GNU Autotools to build). At last, you need to runmake install
, which needs the superuser permission, to copy these files (*.h
,*.so
,*.a
) to the target directory. You can also copy these files manually.In short, you can choose to either compile from source or install from a pre-built package. The advantage of compiling from source is that you can get the latest library.
The issue had no activity for 30 days, mark with Stale label.