Search code examples
c++webrtcprotocol-buffersgrpcunreal-engine4

[UE4]error LNK2005 on linking libprotobuf


Having a small issue with conflicting libraries while packaging an Unreal Engine 4.27 project.

My project contains this gRPC library from google and I followed these steps to build it with CMake and after include it in my Unreal Project.

In addition my project requires enabling PixelStreaming plugin. However it seems that this plugin imported another version of protobuf which, on packaging is conflicting with the one included in gRPC.

The error is the following:

libprotobuf.lib(coded_stream.obj) : error LNK2005: "public: __cdecl google::protobuf::io::CodedOutputStream::CodedOutputStream(class google::protobuf::io::ZeroCopyOutputStream *,bool)" (??0CodedOutputStream@io@protobuf@google@@QEAA@PEAVZeroCopyOutputStream@123@_N@Z) already defined in webrtc.lib(coded_stream.obj)

appearing for different objs.

I came across similar issues as such but disabling gRPC is not a feasible solution for me.

  • Could anyone advise on how to "instruct" the built gRPC to use the existing protobuf library from Pixel Streaming plugin?
  • Which steps do I need to take to properly configure these conflicting libraries?

Solution

  • What solved my issue was migrating to UE5.

    Using the same steps with aforementioned grpc project, in UE5 new project. Having a libprotobuf.lib in ThirdPary folder within UE5 project the packaging process worked with no LINK conflicts. Not sure why UE packaging did not complain this time but what works, works!