Install Protocol Buffers on Windows

前端 未结 8 1131
渐次进展
渐次进展 2021-02-01 14:18

I am unable to find clear instructions to install Google Protocol Buffers (including compiler) on Windows x64 platform.

I went through the instructions README file for c

相关标签:
8条回答
  • 2021-02-01 15:00

    I'd recommend using vcpkg tool on windows. Here is step by step manual.

    Regarding protobuf, firstly check what options you have (in cmd):

    vcpkg search protobuf

    Next install the required package: vcpkg install protobuf:x64-windows-static

    Notice x64-windows-static after the colon - this is the triplet. Check vcpkg help triplet for all of them.

    Then go to your_path\vcpkg-master\packages\protobuf_x64-windows-static\

    Now you can set your environment variables.

    0 讨论(0)
  • 2021-02-01 15:01

    Now protobuf is a NuGet package in Visual Studio. Just go get that.

    0 讨论(0)
  • 2021-02-01 15:13

    If you just want to compile ProtoBuf definitions, you can download precompiled binaries of protoc for all platforms right on the ProtoBuf GitHub releases page.

    They had precompiled binaries at least since 2015, but it's easy to overlook them in between the many downloads.

    0 讨论(0)
  • 2021-02-01 15:17

    I installed it with chocolatey and it worked perfectly.

    choco --install -y protoc
    
    0 讨论(0)
  • 2021-02-01 15:19

    just easy ref

    choco install protoc --pre
    
    0 讨论(0)
  • 2021-02-01 15:20

    There is a whole documentation file for compiling protobuf on Windows :

    • https://github.com/google/protobuf/blob/master/src/README.md#c-installation---windows
    • https://github.com/google/protobuf/blob/master/cmake/README.md

    You'll need 7-zip, Cmake and Visual Studio.

    Anyway, one of the unexpected side-effects of using a Continuous Integration tool (like Travis or Appveyor) is that there is always a up-to-date and working build script available. I happen to always look at appveyor.yml and travis_config.yml files whenever they exists.

    >>> git clone -b v3.1.0 https://github.com/google/protobuf.git 
    >>> cd protobuf
    >>> curl -L -o release-1.7.0.zip https://github.com/google/googlemock/archive/release-1.7.0.zip
    >>> 7z x release-1.7.0.zip
    >>> del /Q release-1.7.0.zip
    >>> rename googlemock-release-1.7.0 gmock
    >>> curl -L -o release-1.7.0.zip "https://github.com/google/googletest/archive/release-1.7.0.zip"
    >>> 7z x release-1.7.0.zip
    >>> del /Q release-1.7.0.zip
    >>> rename googletest-release-1.7.0 gtest
    >>> move gtest gmock
    >>> set generator=Visual Studio 12 Win64
    >>> set vcplatform=x64
    >>> mkdir build_msvc
    >>> cd build_msvc
    >>> cmake -G "%generator%" -Dprotobuf_BUILD_SHARED_LIBS=%BUILD_DLL% -Dprotobuf_UNICODE=%UNICODE% ../cmake
    >>> msbuild protobuf.sln /p:Platform=%vcplatform% || goto error
    

    You'll need curl (Git Bash has it) as well as resolving paths for the 7z.exe and Msbuild.exe executables.

    I successfully managed to build the protobuf compiler on a Windows 10 x64 machine with Visual Studio 2015.

    0 讨论(0)
提交回复
热议问题