'Install Protocol Buffers on Windows

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 compiler and source:

For Compiler: To install, simply place this binary somewhere in your PATH

I added system variable to Path:

PROTOC 'C:\dev_tools\protoc-2.4.1-win32'

I am stuck on installing Protocol Buffers source using Cygwin. I tried following Unix instructions provided in the readme file:

To build and install the C++ Protocol Buffer runtime and the Protocol Buffer compiler (protoc) execute the following:

$ ./configure
$ make
$ make check
$ make install

If make check fails, you can still install, but it is likely that some features of this library will not work correctly on your system. Proceed at your own risk.

make install may require superuser privileges.

For advanced usage information on configure and make, see INSTALL.txt.

** Hint on install location **

By default, the package will be installed to /usr/local. However, on many platforms, /usr/local/lib is not part of LD_LIBRARY_PATH. You can add it, but it may be easier to just install to /usr> instead. To do this, invoke configure as follows:

./configure --prefix=/usr

I get

-bash: ./configure: No such file or directory'

Can some one provide clear and detailed steps to make this work?

UPDATE

I switched to using MSYS/MINGW32 instead and I followed instructions given in this link. Now I am stuck with following:

When I run the './configure' command I get following error:
checking how to run the C++ preprocessor... /lib/cpp
configure: error: C++ preprocessor "/lib/cpp" fails sanity check'

As a result, none of the make, make install commands work. For eg:

make: No targets specified and no makefile found. Stop.


Solution 1:[1]

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.

Solution 2:[2]

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

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.

Solution 3:[3]

For installing proto buff in windows

Go to https://github.com/protocolbuffers/protobuf/releases

Scroll down and download the zip for windows compatible

Binary File

Once download the zip, extract it to C:/

Just copy the path, C:\protoc-3.17.3-win64\bin and set this as path to an environment variables

path setup

Hope, this helps!

Solution 4:[4]

Use chocolatey

choco install protoc

Solution 5:[5]

Download protoc-2.5.0-win32.zip from

https://github.com/protocolbuffers/protobuf/releases/tag/v2.5.0

Then to install, simply place this binary somewhere in your PATH

Solution 6:[6]

I was build protobuf v2.4.1 on Windows 10 as follows:

  • git clone https://github.com/protocolbuffers/protobuf.git;
  • cd protobuf;
  • git checkout v2.4.1;
  • cd vsprojects
  • open protobuf.sln in Visual Studio 2019
  • Press build solution and take many errors: min undefined and max undefined Add in file protobuf/stubs/common.h next code:
#if defined(_WIN32) && !defined(min)
#define min(a,b) __min(a,b)
#define max(a,b) __max(a,b)
#endif
  • Press build solution and take error: fatal error C1189: “#error: hash_map is deprecated and will be REMOVED….
  • Add compile definition -D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS solved problem
  • Next I had error “error C2664: "std::pair std::make_pair(_Ty1 &&,_Ty2 &&) noexcept”…
  • In file src\google\protobuf\compiler\command_line_interface.cc I modified string “proto_path_.push_back(make_pair< string, string >(virtual_path, disk_path));” to “proto_path_.push_back(make_pair(virtual_path, disk_path));
  • Press build solution. All build succeed.(Tests projects not build without test framework)

    INSTALL:

  • Run extract_includes.bat to copy all the public headers into a separate "include" directory (under the top-level package directory).
  • Copy the contents of the include directory to wherever you want to put headers
  • Copy protoc.exe wherever you put build tools
  • copy libprotobuf.lib, libprotobuf-lite.lib, and libprotoc.lib wherever you put libraries.

Solution 7:[7]

I installed it with chocolatey and it worked perfectly.

choco --install -y protoc

Solution 8:[8]

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

enter image description here

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\

enter image description here

Now you can set your environment variables.

Solution 9:[9]

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

Solution 10:[10]

just easy ref

choco install protoc --pre

Solution 11:[11]

choco install protoc --pre worked for, make sure your in an elevated state.

this is the output when I ran protoc from gitbash

$ protoc Usage: C:\ProgramData\chocolatey\lib\protoc\tools\bin\protoc.exe [OPTION] PROTO_FILES Parse PROTO_FILES and generate output based on the options given: -IPATH, --proto_path=PATH Specify the directory in which to search for

adding it to my $path environment variables didn't work from me as expected.