Windows and Apache Thrift Executable

☆樱花仙子☆ 提交于 2020-01-05 04:50:11

问题


I am testing out how simple Apache Thrift is to learn and it looks promising. One major problem: the first tutorial doesn't work...

I have Windows 7, Python 2.7, and got the Thrift .exe for Windows v.0.9.1. I'd rather not compile from source as I don't use Cygwin etc. The exe gave the problems described below. So I moved on and tried using Chocolatey to install Thrift using cinst Thrift which worked fine and gave me Thrift v0.9.0. But this version results in the same behavior as the exe, described below.

When I run the tutorial found at http://thrift.apache.org/tutorial/py I get the following:

C:\Users\Me\Desktop\Thrift>thrift -r --gen py tutorial.thrift
[WARNING:C:/Users/Me/Desktop/Thrift/tutorial.thrift:59] Could not find include file shared.thrift

[ERROR:C:/Users/Me/Desktop/Thrift/tutorial.thrift:123] (last token was 'shared.SharedService')
Service "shared.SharedService" has not been defined.

Hopefully the exe works for someone because I'd love to avoid this requiring a build from source.


回答1:


The answer is that the tutorial assumes you have a /tutorial folder with two .thrift files included in it. If you go the Windows EXE route and then build your tutorial.thrift file, you will also need to add shared.thrift which can be found in Git at https://git-wip-us.apache.org/repos/asf?p=thrift.git;a=blob_plain;f=tutorial/shared.thrift

Save this file next to your tutorial.thrift file and you can proceed with the tutorial.




回答2:


The command

thrift -r --gen py tutorial.thrift

uses the -r[recurse] switch to automatically build a second, included IDL file shared.thrift. This shared.thrift file is located in the same folder as tutorial.thrift is. Because Thrift looks for included files based on the current folder, you have to explicitly call the Thrift compiler from that folder.

Assumed, your Thrift working copy is under C:\Thrift and the thrift.exe is reachable via search path, open a command prompt, navigate to that folder and enter the command again:

C:\> cd Thrift\tutorial
C:\Thrift\tutorial> thrift.exe -r --gen py tutorial.thrift

PS: The 0.9.0 is slightly outdated. The 0.9.1 is fine, the forthcoming release 0.9.2 will have even more improvements.



来源:https://stackoverflow.com/questions/23163260/windows-and-apache-thrift-executable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!