# Compile protobuf on linux for ue4

**URL:** <https://forums.unrealengine.com/t/compile-protobuf-on-linux-for-ue4/483266>\
**Category:** Plugins\
**Tags:** third-party-librarie, unreal-engine, Plugins, CPP, question\
**Created:** [May 12, 2021, 8:53am UTC](https://forums.unrealengine.com/t/compile-protobuf-on-linux-for-ue4/483266 "2021-05-12T08:53:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![LuooYu](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@LuooYu](https://forums.unrealengine.com/u/LuooYu)\
**Post date:** [May 12, 2021, 8:53am UTC](https://forums.unrealengine.com/t/compile-protobuf-on-linux-for-ue4/483266/1 "2021-05-12T08:53:27Z")

</div>

Hi,

Platform: Ubuntu 20.04  
Compiler: clang++ 10.0.0

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.

Does anyone know how to fix it?

---

<div class="post-metadata">

**Author:** ![bombush](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@bombush](https://forums.unrealengine.com/u/bombush)\
**Post date:** [February 16, 2022, 1:22pm UTC](https://forums.unrealengine.com/t/compile-protobuf-on-linux-for-ue4/483266/2 "2022-02-16T13:22:24Z")

</div>

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 .

---

<div class="post-metadata">

**Author:** ![zos](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@zos](https://forums.unrealengine.com/u/zos)\
**Post date:** [July 7, 2022, 1:34am UTC](https://forums.unrealengine.com/t/compile-protobuf-on-linux-for-ue4/483266/3 "2022-07-07T01:34:01Z")

</div>

I figured this out.

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:

[https://raw.githubusercontent.com/FuryGamesPtyLtd/Tasmania/main/Source/GoogleProtocolBuffers/Build.sh](https://raw.githubusercontent.com/FuryGamesPtyLtd/Tasmania/main/Source/GoogleProtocolBuffers/Build.sh)

(I got the options from `LinuxToolChain.cs` in UnrealBuildTool.)

(You’ll need to adjust for your unreal source paths of course)

And there is a checkin of the binary result libprotobuf.a in our public Tasmania plugin:

> **[GitHub - FuryGamesPtyLtd/Tasmania: Unreal plugin with third party libraries](https://github.com/FuryGamesPtyLtd/Tasmania/)**
>
> Unreal plugin with third party libraries. Contribute to FuryGamesPtyLtd/Tasmania development by creating an account on GitHub.

I have tested this as linking against monolithic targets. More work needs to be done - but at least the linking problem is fixed.

---

<div class="post-metadata">

**Author:** ![rqhnaruto](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@rqhnaruto](https://forums.unrealengine.com/u/rqhnaruto)\
**Post date:** [April 9, 2023, 6:58am UTC](https://forums.unrealengine.com/t/compile-protobuf-on-linux-for-ue4/483266/4 "2023-04-09T06:58:54Z")

</div>

🙏
