在 Windows 上安装 Protocol Buffers

问题描述 投票:0回答:6

我无法找到在 Windows x64 平台上安装 Google Protocol Buffers(包括编译器)的明确说明。

我浏览了编译器和源代码的自述文件说明:

对于编译器:要安装,只需将此二进制文件放在路径中的某个位置

我将系统变量添加到路径:

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

我一直坚持使用 Cygwin 安装 Protocol Buffers 源。我尝试跟随 自述文件中提供了 Unix 说明:

构建并安装 C++ Protocol Buffer 运行时和协议 缓冲区编译器(协议)执行以下操作:

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

如果

make check
失败,你仍然可以安装,但很可能 该库的某些功能将无法在您的系统上正常工作。 请自行承担风险。

make install
可能需要超级用户权限。

有关配置和制作的高级使用信息,请参阅 INSTALL.txt。

** 安装位置提示 **

默认情况下,软件包将安装到/usr/local。但是,在许多平台上,/usr/local/lib 不是 LD_LIBRARY_PATH 的一部分。您可以添加它,但安装到 /usr> 可能会更容易。为此,请按如下方式调用配置:

./configure --prefix=/usr

我明白了

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

有人可以提供清晰详细的步骤来完成这项工作吗?

更新

我转而使用 MSYS/MINGW32 并 我按照此链接中给出的说明进行操作。现在我陷入了以下困境:

当我运行“./configure”命令时,出现以下错误:
检查如何运行 C++ 预处理器... /lib/cpp
配置:错误:C++ 预处理器“/lib/cpp”未通过健全性检查'

因此,make、make install 命令都不起作用。例如:

make: No targets specified and no makefile found. Stop.
java windows cygwin mingw protocol-buffers
6个回答
27
投票

用于在 Windows 中安装 proto buff

前往 https://github.com/protocolbuffers/protobuf/releases

向下滚动并下载 Windows 兼容的 zip

下载 zip 后,将其解压到 C:/

只需复制路径,

 C:\protoc-3.17.3-win64\bin
并将其设置为环境变量的路径

希望,这有帮助!


26
投票

如果您只想编译 ProtoBuf 定义,您可以直接在 ProtoBuf GitHub 发布页面上下载适用于所有平台的 protoc 预编译二进制文件。

他们至少从 2015 年起就已经预编译了二进制文件,但在多次下载之间很容易忽视它们。


18
投票
有一个用于在 Windows 上编译 protobuf 的完整文档文件:

  • https://github.com/google/protobuf/blob/master/src/README.md#c-installation---windows
  • https://github.com/google/protobuf/blob/master/cmake/README.md
您需要 7-zip、Cmake 和 Visual Studio。

无论如何,使用持续集成工具(如 Travis 或 Appveyor)的意外副作用之一是始终有可用的最新且有效的构建脚本。我碰巧总是查看

appveyor.yml

travis_config.yml
 文件,只要它们存在。

>>> 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

您需要

curl

Git Bash
 有)以及 
7z.exe
Msbuild.exe
 可执行文件的解析路径。

我成功地使用 Visual Studio 2015 在 Windows 10 x64 计算机上构建了 protobuf 编译器。


15
投票
使用

巧克力

choco install protoc


    


6
投票

下载 protoc-2.5.0-win32.zip

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

然后安装,只需将此二进制文件放置在您的路径中的某个位置


4
投票
我在 Windows 10 上构建了

protobuf v2.4.1 ,如下所示:

    git克隆
  • https://github.com/protocolbuffers/protobuf.git;
  • cd protobuf;
  • git checkout v2.4.1;
  • cd vsprojects
  • 在 Visual Studio 2019 中打开 protobuf.sln
  • 按构建解决方案并出现许多错误:min undefined 和 max undefined 在文件 protobuf/stubs/common.h 中添加下一个代码:
#if defined(_WIN32) && !defined(min) #define min(a,b) __min(a,b) #define max(a,b) __max(a,b) #endif


    按构建解决方案并出现错误:
  • 致命错误 C1189:“#error:hash_map 已弃用,将被删除......
  • 添加编译定义
  • -D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS解决了问题
  • 接下来我遇到了错误“
  • error C2664:“std::pair std::make_pair(_Ty1 &&,_Ty2 &&) noexcept”…
  • 在文件 src\google\protobu 中
© www.soinside.com 2019 - 2024. All rights reserved.