Undefined symbol in protoc with gcc 11 build

Viewed 1067

I'm trying to build protocol-buffer by following these instructions.

This is what I did.

git clone https://github.com/protocolbuffers/protobuf.git
cd protobuf
git submodule update --init --recursive
./autogen.sh
./configure
make -j6

After the successful build, I checked

ldd -d src/.libs/protoc

It showed a lot of undefined symbols.

root@renju-mc:~/.../protobuf# ldd -d src/.libs/protoc
        linux-vdso.so.1 (0x00007fff1f3a5000)
        libprotoc.so.28 => not found
        libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fdce230c000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fdce20f4000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fdce1d03000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fdce1965000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fdce291d000)
undefined symbol: _ZN6google8protobuf8compiler20CommandLineInterface12AllowPluginsERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE       (src/.libs/protoc)
undefined symbol: _ZN6google8protobuf8compiler20CommandLineInterface3RunEiPKPKc (src/.libs/protoc)
undefined symbol: _ZN6google8protobuf8compiler20CommandLineInterfaceD1Ev        (src/.libs/protoc)
undefined symbol: _ZN6google8protobuf8compiler6csharp9GeneratorC1Ev     (src/.libs/protoc)
undefined symbol: _ZN6google8protobuf8compiler6python9GeneratorC1Ev     (src/.libs/protoc)
undefined symbol: _ZN6google8protobuf8compiler20CommandLineInterface17RegisterGeneratorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_PNS1_13CodeGeneratorESA_   (src/.libs/protoc)
undefined symbol: _ZN6google8protobuf8compiler20CommandLineInterfaceC1Ev        (src/.libs/protoc)
undefined symbol: _ZN6google8protobuf8compiler4java13JavaGeneratorD1Ev  (src/.libs/protoc)
undefined symbol: _ZN6google8protobuf8compiler13CodeGeneratorD2Ev       (src/.libs/protoc)
undefined symbol: _ZN6google8protobuf8compiler4java15KotlinGeneratorC1Ev        (src/.libs/protoc)
undefined symbol: _ZN6google8protobuf8compiler6csharp9GeneratorD1Ev     (src/.libs/protoc)
undefined symbol: _ZN6google8protobuf8compiler3cpp12CppGeneratorD1Ev    (src/.libs/protoc)
undefined symbol: _ZN6google8protobuf8compiler10objectivec19ObjectiveCGeneratorC1Ev     (src/.libs/protoc)
undefined symbol: _ZN6google8protobuf8compiler4java15KotlinGeneratorD1Ev        (src/.libs/protoc)
undefined symbol: _ZN6google8protobuf8compiler10objectivec19ObjectiveCGeneratorD1Ev     (src/.libs/protoc)
undefined symbol: _ZN6google8protobuf8compiler3cpp12CppGeneratorC1Ev    (src/.libs/protoc)
undefined symbol: _ZN6google8protobuf8compiler4java13JavaGeneratorC1Ev  (src/.libs/protoc)
undefined symbol: _ZN6google8protobuf8compiler6python9GeneratorD1Ev     (src/.libs/protoc)

libprotoc.so.28 => not found this file is present at the same location as of protoc.

root@renju-mc:~/.../protobuf# ls -l src/.libs/libprotoc.so.28
lrwxrwxrwx 1 root root 19 Jul 25 22:20 src/.libs/libprotoc.so.28 -> libprotoc.so.28.0.3

I'm using Ubuntu 18.04, with gcc-11.

gcc version 11.1.0 (Ubuntu 11.1.0-1ubuntu1~18.04.1)
2 Answers

The Linux loader, ld.so does not, by default, load libraries from the current directory but only from predefined locations.

You are attempting to load a library from the current directory that depends on another library in the current directory, hence the load failure.

ld.so's manual page explains how to set LD_LIBRARY_PATH in order change this behavior.

It will probably work better if you follow all the instructions including the step "make install". Usually "make install" places built dynamic libraries in some standard location like /usr/local/lib where the dynamic linker will find them.

If you for some reason do not want to install the software you can use the environment variable LD_LIBRARY_PATH to point out your non standard directory containing dynamic libraries. Example: export LD_LIBRARY_PATH=src/.libs

Related