Protoc error in Windows

I'm trying to compile protocol buffers code using the maven protoc plugin and a protoc executable that I built inside Cygwin. I can't do this from Cygwin or from the Windows command line. Below is the output that I get when I run it in Windows, but the error is identical when running from Cygwin. I find this strange because if the issue was with path translation then I'd expect one of them to work. Is it possible that the fact that the executable was built with Cygwin's g++ could affect things? (To state the obvious, the directory in question does exist.)

Edit: I get the same error when I take maven out of the picture and just invoke protoc by hand.

Edit 2: I can fix this by invoking protoc by hand from Cygwin using relative or absolute paths (but tilde-expansion does not work). Invoking protoc by hand from Windows using relative or absolute paths continues to give the same error.

[DEBUG]   (f) outputDirectory = c:cygwin64homedancodeserverprotocoltargetgenerated-sourcesprotobufjava
[DEBUG]   (f) project = MavenProject: server:protocol:1.0-SNAPSHOT @ c:cygwin64homedancodeserverprotocolpom.xml
[DEBUG]   (f) protoSourceRoot = c:cygwin64homedancodeserverprotocolsrcmainproto
[DEBUG]   (f) protocPluginDirectory = c:cygwin64homedancodeserverprotocoltargetprotoc-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:cygwin64homedancodeserverprotocoltargetprotoc-dependencies
[DEBUG]   (f) writeDescriptorSet = false
[DEBUG] -- end configuration --
[WARNING] No 'protocExecutable' parameter is configured, using the default: 'protoc'
[DEBUG] Proto source root:
[DEBUG]  c:cygwin64homedancodeserverprotocolsrcmainproto
[DEBUG] [PROTOC] Executable:
[DEBUG] [PROTOC]  protoc
[DEBUG] [PROTOC] Protobuf import paths:
[DEBUG] [PROTOC]  c:cygwin64homedancodeserverprotocolsrcmainproto [DEBUG] [PROTOC] Java output directory:
[DEBUG] [PROTOC]  c:cygwin64homedancodeserverprotocoltargetgenerated-sourcesprotobufjava
[DEBUG] [PROTOC] Protobuf descriptors:
[DEBUG] [PROTOC]  c:cygwin64homedancodeserverprotocolsrcmainprotomessage.proto
[DEBUG] [PROTOC] Command line options:
[DEBUG] [PROTOC]
    --proto_path=c:cygwin64homedancodeserverprotocolsrcmainproto
    --java_out=c:cygwin64homedancodeserverprotocoltargetgenerated-sourcesprotobufjava
    c:cygwin64homedancodeserverprotocolsrcmainprotomessage.proto
[INFO] Compiling 1 proto file(s) to c:cygwin64homedancodeserverprotocoltargetgenerated-sourcesprotobufjava
[ERROR] PROTOC FAILED: c: warning: directory does not exist. c:cygwin64homedancodeserverprotocolsrcmainprotomessage.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).

Executables that you build using Cygwin will depend on the full Cygwin environment and will behave as Cygwin programs, regardless of how you execute them. That is, if you execute a Cygwin program from the non-Cygwin shell, it will still behave as a Cygwin program. Cygwin programs do not accept Windows-style paths that use backslashes an drive letters; you need to use eg /cygdrive/c/ instead of c: .

In general, you should not attempt to use Cygwin-compiled command-line tools from a non-Cygwin shell. Instead, try building protoc using MSVC or MinGW, or use the pre-built Windows binaries that Google provides.

链接地址: http://www.djcxy.com/p/64790.html

上一篇: 使用Google协议生成C#文件失败

下一篇: Windows中的Protoc错误