libprotobuf for Unreal Engine 4
Link the google's protocol bufffers
library as the third party in Unreal Engine 4.
- Import or copy the folder 'libprotobuf' into
<your project>/Source/ThirdParty/libprotobuf
. - Add the libprotobuf as a module into
<your project>.Build.cs
PrivateDependencyModuleNames.AddRange(new string[] { "CoreUObject", "Engine", "libprotobuf" });
- Generate two code files (header & source, ex: Message.pb.h & Message.pb.cc) of the protocal by
protoc
forcpp
. (Ref: Google's Protocol Buffers) - Put them into the source directory (
Private
orPublic
) of your project. - Add these line in message cpp file(Mesage.pb.cc)
#ifdef _MSC_VER
#pragma warning(disable:4125)
#endif
- Regenerate the code file for Unreal Engine 4 by
regenerateforue4.py
.python regenerateforue4.py 'the header file'
- ex:
python regenerateforue4.py Message.pb.h
- You should get this information:
Success to regenerate the code for UE4
- Include and use the header file(ex: Message.pb.h) in your
.cpp
file. - That's all.