# UE4Protobuf **Repository Path**: itwarcraft/UE4Protobuf ## Basic Information - **Project Name**: UE4Protobuf - **Description**: UE4中编译最新Protobuf 3.11.2的脚本 - **Primary Language**: C++ - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 6 - **Created**: 2023-07-19 - **Last Updated**: 2023-07-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # ue4pb 编译UE使用的protobuf ## 编译环境 1. Windows下编译Win64及Android库及UE使用的Linux库 * Visual Studio * Android NDK * CMake 并将cmake.exe所在目录加入系统变量`PATH`中 * 从UE官网下载 Cross-Compile Toolchains 2. Mac机编译Mac及IOS库 * XCode * CMake ## 使用说明 1. 下载[Google Protobuf](https://github.com/protocolbuffers/protobuf/releases)最新版(protobuf-cpp-x.x.x.zip)。 2. 解压并改名为`source`目录 3. 修改源代码 * source\src\google\protobuf\compiler\cpp\file.cc ```diff // 方法:FileGenerator::GenerateSourceIncludes format( "// Generated by the protocol buffer compiler. DO NOT EDIT!\n" "// source: $filename$\n" + "\n" + "// Disable UE4 VS warnings\n" + "#ifdef _MSC_VER\n" + "#\tpragma warning(disable: 4946)\n" + "#\tpragma warning(disable: 4125)\n" + "#\tpragma warning(disable: 4647)\n" + "#\tpragma warning(disable: 4668)\n" + "#\tpragma warning(disable: 4800)\n" + "#endif\n" + "\n" "#include $1$\n" ``` 4. 编译 * 运行VS的`x64 Native Tools Command Prompt for VS XXX`,**cd**到工程目录执行`BuildWindows.bat` * 修改`BuildAndroid.bat`中**NDK**的路径 * 修改`BuildLinux.bat`中的**UE**所在路径 * 编译Mac及IOS: + STEP.1 Windows下共享工程目录 + STEP.2 Mac机下使用`mount_smbfs`指令挂载该目录 + STEP.3 执行`BuildIOS`及`BuildMac` 5. UE4集成 * 在项目`Source/ThirdParty`目录下建立文件夹`Protobuf` * 将`include`, `lib`, `Protobuf.Build.cs`拷贝到新建的目录下 * 使用`bin`目录下生成`protoc.exe`生成`*.pb.cc`及`*.pb.h`文件