Troubleshooting: undefined reference to `google::protobuf

719 views
Skip to first unread message

OneCalledFlo

unread,
Jul 29, 2022, 6:18:37 AM7/29/22
to Protocol Buffers
Hello!
I am trying to resurrect a project from 2020 which is using protobuf.

It comes with a script to install dependencies wich installs protobuf like this:
 wget https://github.com/google/protobuf/releases/download/v${PROTO_V}/protobuf-all-${PROTO_V}.zip > /dev/null
  unzip protobuf-all-${PROTO_V} > /dev/null
  cd protobuf-${PROTO_V}
  ./autogen.sh > /dev/null
  if [ "$COMPILER" = "clang++" ]; then
    ./configure CXX=clang++ CXXFLAGS='-std=c++11 -stdlib=libc++ -O3 -g' > /dev/null
  else
    ./configure CXX=g++ CXXFLAGS='-std=c++11 -O3 -g' > /dev/null
  fi

  make -j4 > /dev/null
  sudo make install > /dev/null
  sudo ldconfig > /dev/null

which seems to work:
protoc --version
libprotoc 3.9.1

The project is then compiled via another script which does so by either using Clang (version 5 or newer) or gcc (version 7 or newer) (according to doc).

I've got
gcc version 11.2.0 (Ubuntu 11.2.0-19ubuntu1)
Ubuntu clang version 14.0.0-1ubuntu1

installed.

However when trying to compile I get like 50+ of those errors:
undefined reference to `google::protobuf::.....

While googeling for a fix, I found that this may have to do with an update to the compilers, however non of the fixes I found seemed to work out for me :(

Can anyone help me out on this?

Looking forward to hearing from you,
Florian

Deanna Garcia

unread,
Aug 1, 2022, 1:23:26 PM8/1/22
to Protocol Buffers
3.9.1 is a very old version of protobuf. If it's possible to upgrade to a newer version you would get access to newer features and we can support/debug easier. Is there any reason to stay at 3.9.1? If you change that will it fix the problem?

When you say "trying to compile" what command are you running exactly?

OneCalledFlo

unread,
Aug 1, 2022, 1:58:34 PM8/1/22
to Protocol Buffers
First of all: Thanks for your  response!

Yeah I noticed that aswell (the version being very old).
I haven't done any work on the project myself yet thats why I didnt bother upgrading yet.
Is it possible to upgrade without getting into any version conflicts?

The command I'm trying to compile with is:

cmake -std=c++11 "-GUnix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=$COMPILER  ..
make -j2

with $COMPILER beeing set to either "/usr/bin/clang++" or "/usr/bin/g++"

Ive also tried adding -D_GLIBCXX_USE_CXX11_ABI=0 to the command since I read somewhere, that this might fix errors when using old libs with newer compilers
Reply all
Reply to author
Forward
0 new messages