I want to use google protobuf in my project as a plugin, so i download it from github repo and compile it with these params [./configure --prefix=/home/luoyu/Documents/protobuf-3.16.0/install CC=clang CXX=clang++ CXXFLAGS="-O2 -g -DNDEBUG -fPIC" --enable-shared=no].
But when i build my ue project with the libprotobuf.a, it always say undefined symbol xxxxxx.
Hi. Did you have any luck with this? I’m in exactly the same situation now and can’t figure it out.
I even tried to build protobuf using the clang bundled with Unreal but still get “undefined symbol” with the most basic stuff like google::protobuf::internal::ArenaStringPtr::Set or google::protobuf::MessageLite::SerializeToString .
The problem is you need to compile with both the correct C++ toolchain and the correct C++ standard library.
You were on the right track to build with the bundled clang, but you also need to compile against the bundled LibCxx (libc++). By default the bundled clang will build against libstdc++ - and that is what is causing the linking problems (ie protobuf is compiled against a different standard library to the one UnrealBuildTool is compiling the rest of the project against - so there are symbol mismatches when linking.)
Here is the full cmake command line I have found to build protobuf for unreal: