且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

未定义的引用google :: protobuf :: internal :: empty_string_ [abi:cxx11]

更新时间:2021-12-15 15:21:46

我怀疑这是一个C + + ABI问题。在GCC 5(与C ++ 11相关的要求,但它适用,即使你不使用C ++ 11)中更改了 std :: string 的ABI。请参阅:

I suspect this is a C++ ABI issue. The ABI for std::string has changed in GCC 5 (related to C++11 requirements, but it applies even if you aren't using C++11). See:

https://gcc.gnu .org / gcc-5 / changes.html#libstdcxx

如果libprotobuf是使用GCC 4.x或之前版本构建的, 5,那么你会看到问题,因为libprotobuf在其接口中使用 std :: string 。您有两个选项:

If libprotobuf was built with GCC 4.x or prior, but your app is built with GCC 5, then you will see problems, because libprotobuf uses std::string in its interface. You have two options:


  1. 使用GCC 5重建libprotobuf(但现在使用GCC 4构建的任何应用程序都无法使用新版本libprotobuf)。

  2. 如上所述,使用 -D_GLIBCXX_USE_CXX11_ABI = 0 构建应用程序。这将强制GCC使用旧的ABI版本。

  1. Rebuild libprotobuf with GCC 5 (but now any apps built with GCC 4 won't work with the new version of libprotobuf).
  2. Build you app with -D_GLIBCXX_USE_CXX11_ABI=0 as described at the above link. This will force GCC to use the old ABI version.