我正在尝试使用maven protoc plugin和我在Cygwin中构建的protoc可执行文件来编译协议缓冲区代码 . 我希望其中一个能够奏效 . 可执行文件是否可能使用Cygwin的g构建可能会影响事情? (说明显而易见,有问题的目录确实存在 . )
编辑:当我从图片中取出maven并手动调用protoc时,我得到了同样的错误 .
编辑2:我可以通过使用相对或绝对路径从Cygwin手动调用protoc来解决这个问题(但是波浪扩展不起作用) . 使用相对路径或绝对路径从Windows手动调用protoc会继续产生相同的错误 .
[DEBUG] (f) outputDirectory = c:\cygwin64\home\dan\code\server\protocol\target\generated-sources\protobuf\java
[DEBUG] (f) project = MavenProject: server:protocol:1.0-SNAPSHOT @ c:\cygwin64\home\dan\code\server\protocol\pom.xml
[DEBUG] (f) protoSourceRoot = c:\cygwin64\home\dan\code\server\protocol\src\main\proto
[DEBUG] (f) protocPluginDirectory = c:\cygwin64\home\dan\code\server\protocol\target\protoc-plugins
[DEBUG] (f) remoteRepositories = [
id: central
url: https://repo.maven.apache.org/maven2
layout: default snapshots: [enabled => false, update => daily]
releases: [enabled => true, update => daily]
]
[DEBUG] (f) session = org.apache.maven.execution.MavenSession@24fb6a80
[DEBUG] (f) skip = false
[DEBUG] (f) staleMillis = 0
[DEBUG] (f) temporaryProtoFileDirectory = c:\cygwin64\home\dan\code\server\protocol\target\protoc-dependencies
[DEBUG] (f) writeDescriptorSet = false
[DEBUG] -- end configuration --
[WARNING] No 'protocExecutable' parameter is configured, using the default: 'protoc'
[DEBUG] Proto source root:
[DEBUG] c:\cygwin64\home\dan\code\server\protocol\src\main\proto
[DEBUG] [PROTOC] Executable:
[DEBUG] [PROTOC] protoc
[DEBUG] [PROTOC] Protobuf import paths:
[DEBUG] [PROTOC] c:\cygwin64\home\dan\code\server\protocol\src\main\proto [DEBUG] [PROTOC] Java output directory:
[DEBUG] [PROTOC] c:\cygwin64\home\dan\code\server\protocol\target\generated-sources\protobuf\java
[DEBUG] [PROTOC] Protobuf descriptors:
[DEBUG] [PROTOC] c:\cygwin64\home\dan\code\server\protocol\src\main\proto\message.proto
[DEBUG] [PROTOC] Command line options:
[DEBUG] [PROTOC]
--proto_path=c:\cygwin64\home\dan\code\server\protocol\src\main\proto
--java_out=c:\cygwin64\home\dan\code\server\protocol\target\generated-sources\protobuf\java
c:\cygwin64\home\dan\code\server\protocol\src\main\proto\message.proto
[INFO] Compiling 1 proto file(s) to c:\cygwin64\home\dan\code\server\protocol\target\generated-sources\protobuf\java
[ERROR] PROTOC FAILED: c: warning: directory does not exist. c:\cygwin64\home\dan\code\server\protocol\src\main\proto\message.proto: File does not reside within any path specified using --proto_path (or -I). You must specify a --proto_path which encompasses this file. Note that the proto_path must be an exact prefix of the .proto file names -- protoc is too dumb to figure out when two paths (e.g. absolute and relative) are equivalent (it's harder than you think).
1 回答
使用Cygwin构建的可执行文件将依赖于完整的Cygwin环境,并且无论您如何执行它们,它们都将表现为Cygwin程序 . 也就是说,如果从非Cygwin shell执行Cygwin程序,它仍将表现为Cygwin程序 . Cygwin程序不接受使用反斜杠驱动器字母的Windows风格路径;你需要使用例如
/cygdrive/c/
而不是c:\
.通常,您不应尝试从非Cygwin shell使用Cygwin编译的命令行工具 . 相反,尝试使用MSVC或MinGW构建
protoc
,或使用Google提供的预构建的Windows二进制文件 .