Add grpc and protobuf to Ue4 ,build failed without libcxx,

Hi, there:

I want to add grpc and protobuf to my ue4 project. I have success add them on my mac by add include file and libs. but when I try on linux (ubuntu 16.04, build ue4 16.3 release version from source code). Something is Wrong:

Firstly, when I run the project, it said ‘undefined symbol _ZNK6google8protobuf7Message11GetTypeNameEv’ because of protobuf head file compiled by ue4 build tool , but I have ‘_ZNK6google8protobuf7Message11GetTypeNameB5cxx11Ev’ in binary file , witch build with local c++ libs.

Secondly, I use the ‘UE4_LINUX_USE_LIBCXX=0’ and try to build ue4 with local c++libs, but I found that, many third party libs only have head files and *.a lib witch has been build with LibCxx(I think). Maybe I shoud not use ‘UE4_LINUX_USE_LIBCXX=0’.

So , what shoud I do, try to build protobuf and grpc use clang and Libcxx? It looks still many problems about it.

Hey liweimin90-

There are a couple of things I’d like to address. First, make sure that you compile grpc and protobuf libs using the same compiler and the same C++ library as the main engine. Make sure that the same C++ standard is passed to both too (engine uses -std=c++14 since 4.15)

Secondly, you will need to rebuild bundled third party libraries to use local C++ libraries as well. The sources are included in the engine distribution. Let me know if this info helps.

Cheers

Thanks . Finally, I compiled protobuf and grpc with clang and LibCxx,it works. But when i stop the UE4Editor, it core dumped. I will try to fix it, maybe needs some compile flag.

You can load the core into gdb and bt that. Most likely something gets destroyed too late - make sure you clean up everything on module shutdown.

Hi , thanks for your reply.
What would you say is the better approach: setup a linux machine with the same toolchain as the cross-compiler and build there using existing build scripts (e.g. cmake), or build using the cross-compiler on windows and go through the extra effort of supporting the custom toolchain.

The first approach seems easier, but I’m not sure what issues there might be with other differences between UE4’s cross-compiler and the replicated environment.

Hello. Could you please share the compiler commands and options with which you compiled protobuf? I’m trying to recompile them with same compiler (clang) and options (-std=c++14) used for Unreal Engine, but I still get the same linking error (‘undefined symbol _ZNK6google8protobuf7Message11GetTypeNameEv’). Thanks.

Can anyone share what are the needed configuration to build gRPC using UE4 Linux Toolchain.

I am getting several errors:

ld.lld: error: undefined symbol: std::__throw_out_of_range(char const*)
00:06:11.679 >>> referenced by bind.cc.o: (absl::lts_2020_09_23::str_format_internal::AppendPack(std::string*,

This happens a lot related wih std:: functions in use in gRPC.

I am using CMAKE with DCMAKE_TOOLCHAIN_FILE using UE4 linux clang toolchain.

I would love to see how did you solve the use of LibCxx, I think it’s what is causing errors in my case.

check full command to build grpc here

at the end, I received some “undefined symbol” from abseil, but for the system calls. in this case you could change this functions to analog and recompile abseil.

Hello, finally I got undefined symbols from libwebrtc.a, for example

ld.lld: error: undefined symbol: absl::base_internal::LowLevelAlloc::Free(void*)
UATHelper: 打包 (Linux): >>> referenced by create_thread_identity.cc
UATHelper: 打包 (Linux): >>>               create_thread_identity.o:(absl::synchronization_internal::ReclaimThreadIdentity(void*)) in archive F:/UE4/UE_5.1/Engine/Source/ThirdParty/WebRTC/4664/Lib/Linux/x86_64-unknown-linux-gnu/Release/libwebrtc.a

Is there any specific solution?This Error only happen in absl::base_internal::LowLevelAlloc::Free(void*) and absl::base_internal::LowLevelAlloc::Alloc(unsigned long) .Maybe there’s some special way to handle it.Thanks again

Hello, I have also encountered these undefined errors. Here is my solution.May I ask if this is helpful to you
https://forums.unrealengine.com/t/undefined-symbols-when-using-grpc/1522232?u=cyb201