首页 > 解决方案 > MSYS2 MinGW 包中缺少 Protobuf grpc_cpp_plugin

问题描述

我安装了一个新的 MSYS2 环境,并下载了mingw-w64-x86_64-grpc包含依赖项的包(mingw-w64-protobuf其中之一),并且除了 grpc_cpp_plugin 部分之外,我能够运行 protobuf 命令。makefile 中使用的命令有:

GRPC_CPP_PLUGIN = grpc_cpp_plugin
GRPC_CPP_PLUGIN_PATH ?= `which $(GRPC_CPP_PLUGIN)`

gen: 
    my_file.proto --proto_path="../proto/" --cpp_out="../cxx/gen/" --grpc_out="../cxx/gen"

完全相同的命令可以在 Debian 虚拟机上运行,​​因此已验证该命令本身应该可以运行。

但是,当我尝试使用 protoc 生成文件时收到以下错误消息:

grpc_cpp_plugin: program not found or is not executable.

我查看了 mingw64 bin 文件夹,确实存在 protoc 可执行文件,但缺少 grpc_cpp_plugin。

我尝试从源代码构建 grpc,但无法使其工作,所以也许我认为有一个包可以安装到 MSYS 环境中。

我在另一个答案中找到了一些可执行文件,我复制了它们,但是(我确定是因为版本或架构不匹配)那些无法使用。

我错过了什么?我在哪里可以获得 grpc_cpp_plugin 可执行文件?

标签: c++mingwprotocol-buffersgrpcmsys2

解决方案


这是Windows/MinGW下扩展解析的问题。对 makefile 进行以下更改后,成功生成了协议缓冲区:

GRPC_CPP_PLUGIN = grpc_cpp_plugin.exe # . exe was added so the plugin executable would be found
GRPC_CPP_PLUGIN_PATH ?= `which $(GRPC_CPP_PLUGIN)`

gen: 
    my_file.proto --proto_path="../proto/" --cpp_out="../cxx/gen/" --grpc_out="../cxx/gen"

推荐阅读