I am following the tutorial listed here on Protobuf's website. I copied the sample addressbook.proto
and compiled it using the line
protoc --cpp_out=. addressbook.proto
Which produced addressbook.pb.cc
and addressbook.pb.h
. Here is my program, which doesn't do anything right now (I am just trying to get it to compile).
#include "addressbook.pb.h"
int main(int argc, char *argv[]) {
return 0;
}
My problem arises at compilation. I thought this would suffice:
g++ -std=c++14 main.cpp addressbook.pb.cc -o main -L/usr/local/lib64 -lprotobuf -lprotoc -lprotobuf-lite -lpthread
However, I get enough linker errors to fill my terminal's history, pretty much all of them start with
undefined reference to `absl::lts_20230125:: ...
I tried manually installing Abseil from source by following the directions here, which put the *.a
files in /usr/local/lib64
.
I tried using -L
to specify the original build directory to the linker (before installation).
I found a list of 60-70 Abseil-related linker flags which I tried to incorporate into my compilation command.
I tried various assortments of compiler/linker flags, enivronment variables, and recompiling Protobuf and Abseil, all resulting in the same thing.
For the record, I installed Protocol Buffers from source by following the CMake directions specified here. My GCC version is 8.3.1 (via devtoolset-8 on CentOS 7.9). I made sure to include the -DCMAKE_CXX_STANDARD=14
flag when building. For me, it is installed at /usr/local/lib64
.
I imagine I'm making a simple mistake somewhere or I'm missing something basic since protobuf is a well-known library, but I'm really stumped here. Any help is appreciated!