Skip to content

Using cmake to build protobuf-lite for Unreal Engine 4

Notifications You must be signed in to change notification settings

jisuz/protobuf_ue4_cmake

 
 

Repository files navigation

Build protoc files for Unreal Engine 4 using cmake.

Env:

  • protobuf version is 3.5.1
  • Native build command is nmake
  • cmake version is 3.10
  • Unreal Engine 4 version is 4.18

Windows

1. build protobuf-lite library
  1. open Native Tools Command Prompt command, eg. x64 Native Tools Command Prompt for VS 2017.

  2. Address to directory build_protobuf-lite/ (address to directory build_protobuf/ if you want to build libprotobuf):

    cd build_protobuf-lite

mkdir build & cd build
mkdir release & cd release
cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release ../..
nmake

then libprotobuf-lite.lib would output to directory install/Release/.

protobuf source has been modified, because protobuf 3.x offical source cann't build with UE4. source modify details: https://github.com/jashking/UE4Protobuf

2. generate protoc files
  1. Address to directory test/:

    cd test

  2. execute protoc_gen.bat

then test.pb.h and test.pb.cc would output in directory test/

3. build protoc C++ files
  1. Address to directory test/cmake/:

    cd test/cmake/

mkdir build & cd build
mkdir release & cd release
cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release ../..
nmake

then libtest.lib would output to directory test/install/Release/

4. Configure UE4 Build.cs
  1. copy ue4/MyProj.Build.cs into your UE4 project: MyProj/Source/MyProj/

  2. copy libtest.lib and libprotobuf-lite.lib into your UE4 project: MyProj/ThirdParty/Protobuf/Library/

  3. copy google protobuf headers into your UE4 project: MyProj/ThirdParty/Protobuf/Include/

  4. copy test.pb.h into your UE4 project: MyProj/ThirdParty/Protobuf/Include/

  5. Add bEnableExceptions = true; inside the {ProjectName}.Build.cs constructor.

then your can build your UE4 project with protoc C++ files.

Android NDK

Steps
  1. execute \ndk_build\build.bat

  2. execute test\ndk_build\build.bat

  3. copy ndk_build\obj\local\armeabi-v7a\libprotobuf-lite-ndk.a and test\ndk_build\obj\local\armeabi-v7a\libtest-ndk.a into your UE4 project: MyProj/ThirdParty/Protobuf/Library/

  4. copy headers which are in test\src\ into your UE4 project: MyProj/ThirdParty/Protobuf/Include/

  5. build your UE4 project.

Reference

Offical CMakeList.txt (cpp fiels & included heads)

libprotobuf-lite:
https://github.com/protocolbuffers/protobuf/blob/master/cmake/libprotobuf-lite.cmake

libprotobuf:
https://github.com/protocolbuffers/protobuf/blob/master/cmake/libprotobuf.cmake

About

Using cmake to build protobuf-lite for Unreal Engine 4

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 99.5%
  • Other 0.5%