UE4中集成ProtoBuf


UE4Protobuf: UE4中編譯最新Protobuf 3.11.2的腳本 (gitee.com)

UE4Protobuf

UE4中編譯最新Protobuf 3.11.2的腳本

編譯環境

  1. Windows下編譯Win64及Android庫

    • Visual Studio
    • Android NDK
    • CMake 並將cmake.exe所在目錄加入系統變量PATH
  2. Mac機編譯IOS庫

    • XCode
    • CMake

使用說明

  1. 下載Google Protobuf最新版(protobuf-cpp-x.x.x.zip)。

  2. 解壓到source目錄下

  3. 修改源代碼

    • src/google/protobuf/compiler/cpp/cpp_file.cc

      // 方法: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"
    • cmake/CMakeLists.txt

        add_definitions(-DGOOGLE_PROTOBUF_CMAKE_BUILD)
      + add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI=1)
  4. 編譯

    • 修改BuildWindows.bat中VC的路徑為自己安裝的路徑
    • 修改BuildAndroid.bat中NDK的路徑
    • Windows下運行BuildWindows.bat
    • Windows下運行BuildAndroid.bat
    • Mac下運行BuildIOS.sh
  5. UE4集成

    • 在項目Source/ThirdParty目錄下建立文件夾Protobuf
    • includelibProtobuf.Build.cs拷貝到新建的目錄下
    • 使用bin目錄下生成protoc.exe生成*.pb.cc*.pb.h文件
    • 由於最新的Protobuf已經使用c++11重寫,所以不需要再引入AllowWindowsPlatformTypes.h等文件了,基本不需要改動


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM