2015-06-20 66 views
0

我想編譯使用maven protoc plugin和我在Cygwin內部構建的protoc可執行文件的協議緩衝區代碼。我無法從Cygwin或Windows命令行執行此操作。下面是我在Windows中運行它時得到的輸出,但從Cygwin運行時錯誤是相同的。我覺得這很奇怪,因爲如果問題是路徑翻譯,那麼我希望其中一個工作。可執行文件是用Cygwin的g ++編譯的事實可能會影響事物嗎? (爲了說明問題,有問題的目錄確實存在。)在Windows中的協議錯誤

編輯:當我將maven從圖片中取出並手動調用protoc時,出現同樣的錯誤。

編輯2:我可以通過使用相對路徑或絕對路徑從Cygwin手動調用protoc來解決此問題(但代字符擴展不起作用)。從Windows使用相對或絕對路徑手動調用protoc繼續給出相同的錯誤。你建立使用Cygwin將取決於全面Cygwin環境,並會表現爲Cygwin的方案,無論您是如何執行他們

 
[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 = [email protected] 
[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). 

回答

2

可執行文件。也就是說,如果您從非Cygwin shell執行Cygwin程序,它仍然會像Cygwin程序一樣運行。 Cygwin程序不接受使用反斜槓和驅動器號的Windows風格路徑;你需要使用例如/cygdrive/c/而不是c:\

通常,您不應該嘗試從非Cygwin shell中使用Cygwin編譯的命令行工具。相反,請嘗試使用MSVC或MinGW構建protoc,或者使用Google提供的預構建的Windows二進制文件。