我正在尝试按照 these instructions. 构建 Protocol Buffer
这就是我所做的。
git clone https://github.com/protocolbuffers/protobuf.git
cd protobuf
git submodule update --init --recursive
./autogen.sh
./configure
make -j6
成功构建后,我检查了
ldd -d src/.libs/protoc
它显示了很多 undefined symbol 。
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 => 未找到
此文件与 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
我使用的是 Ubuntu 18.04,带有 gcc-11。
gcc version 11.1.0 (Ubuntu 11.1.0-1ubuntu1~18.04.1)
最佳答案
默认情况下,Linux 加载程序 ld.so
不会从当前目录加载库,而仅从预定义位置加载。
您正在尝试从当前目录加载依赖于当前目录中另一个库的库,因此加载失败。
ld.so
的手册页解释 how to set LD_LIBRARY_PATH
in order change this behavior .
关于c++ - gcc 11 版本的协议(protocol)中 undefined symbol ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68520802/