Env:
- protobuf version is 3.5.1
- Native build command is nmake
- cmake version is 3.10
- Unreal Engine 4 version is 4.18
-
open
Native Tools Command Prompt
command, eg.x64 Native Tools Command Prompt for VS 2017
. -
Address to directory
build_protobuf-lite/
(address to directorybuild_protobuf/
if you want to buildlibprotobuf
):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
-
Address to directory
test/
:cd test
-
execute
protoc_gen.bat
then test.pb.h
and test.pb.cc
would output in directory test/
-
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/
-
copy
ue4/MyProj.Build.cs
into your UE4 project:MyProj/Source/MyProj/
-
copy
libtest.lib
andlibprotobuf-lite.lib
into your UE4 project:MyProj/ThirdParty/Protobuf/Library/
-
copy google protobuf headers into your UE4 project:
MyProj/ThirdParty/Protobuf/Include/
-
copy
test.pb.h
into your UE4 project:MyProj/ThirdParty/Protobuf/Include/
-
Add
bEnableExceptions = true;
inside the {ProjectName}.Build.cs constructor.
then your can build your UE4 project with protoc C++ files.
-
execute
\ndk_build\build.bat
-
execute
test\ndk_build\build.bat
-
copy
ndk_build\obj\local\armeabi-v7a\libprotobuf-lite-ndk.a
andtest\ndk_build\obj\local\armeabi-v7a\libtest-ndk.a
into your UE4 project:MyProj/ThirdParty/Protobuf/Library/
-
copy headers which are in
test\src\
into your UE4 project:MyProj/ThirdParty/Protobuf/Include/
-
build your UE4 project.
libprotobuf-lite:
https://github.com/protocolbuffers/protobuf/blob/master/cmake/libprotobuf-lite.cmake
libprotobuf:
https://github.com/protocolbuffers/protobuf/blob/master/cmake/libprotobuf.cmake