This is an Unreal Engine 4 plugin that integrates Protobuf into the project without requiring you to add system PATH or anything else.
- add the plugin to the project and enable it.
- add the following property to
build.cs
of modules :
PublicDependencyModuleNames.Add("Protobuf");
- Create
.proto
file into project source code folder - Launch the Project in Editor, Click the
Protoc
button.
- Protobuf v3.21.5
- Protobuf v3.5.1
For protobuf v3.21.x
1. Clone Protobuf repo
- Clone to disk
git clone https://github.com/protocolbuffers/protobuf
- Switch to your desired branchs/tags
git checkout <branchs/tags>
- Use adapte script to convert protobuf source
- Copy the conversion result to
Source/Protobuf/ThirdParty/google
in ue4-protobuf dir
- Go to protobuf repo dir
- Alter source code
- src/google/protobuf/compiler/cpp/file.cc -> FileGenerator::GenerateSourceIncludes
format( "// Generated by the protocol buffer compiler. DO NOT EDIT!\n" "// source: $filename$\n" + "\n" + "#ifdef _MSC_VER\n" + "#\tpragma warning(disable: 4125)\n" + "#\tpragma warning(disable: 4647)\n" + "#\tpragma warning(disable: 4668)\n" + "#\tpragma warning(disable: 4800)\n" + "#\tpragma warning(disable: 4946)\n" + "#endif\n" + "\n" "#include $1$\n"
- Run cmd to complie protoc.exe
cd <protobuf repo dir> call <Microsoft Visual Studio Program File>\VC\Auxiliary\Build\vcvars64.bat @REM For example: call "%ProgramFiles%\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat" cmake ./cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_INSTALL_PREFIX=./ -DBUILD_SHARED_LIBS=OFF -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_CONFORMANCE=OFF -Dprotobuf_BUILD_EXAMPLES=OFF -Dprotobuf_BUILD_PROTOC_BINARIES=ON -Dprotobuf_MSVC_STATIC_RUNTIME=OFF nmake -nologo install
- Copy the
/bin/protoc.exe
binary file in protobuf repo dir to/Source/Protobuf/ThirdParty/bin/
in ue4-protobuf dir