You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Mark Schmit <ms...@gmail.com> on 2009/09/07 07:08:32 UTC

No C++ types output from Thrift compiler on Windows

Hey guys,
I'm new to Thrift but am looking forward to playing with it.  Unfortunately
I'm struggling to get a working Thrift compiler on Windows.  I've built
thrift.exe in Cygwin with the no-cygwin-dependency path documented on
http://wiki.apache.org/thrift/ThriftInstallationWin32, but it seems to only
half-work.  For example, when I try to generate C++ code using the tutorial
files, the compiler says this:

[ERROR:c:\development\project\foo\thrift\tutorial.thrift:123] (last
token was 'shared.SharedService')
Service "shared.SharedService" has not been defined.

The same command line works fine on Linux.  Secondly, if I try compiling
shared.thrift directly, I only see SharedService.h/cpp and
SharedService_server.skeleton.cpp, while on Linux I also see
shared_types.h/cpp.  I tried some other sample .thrift files and it seems
like I'm missing all of the thrift-file-related (as opposed to
service-related) C++ files.

I tried generating Java and Python as well.  Java seemed to work correctly,
outputting the same thing on both Linux and Windows.  Python didn't output
*anything* on Windows, while it generated appropriate files and directories
on Linux.

What's going on?  Did I build thrift.exe incorrectly?  Does something about
it not like Windows?  Have others encountered similar problems?  (Any chance
of a binary distribution of thrift.exe so I can expect the compiled binary
to do what it's supposed to?)

-Mark

Re: No C++ types output from Thrift compiler on Windows

Posted by Mark Schmit <ms...@gmail.com>.
I decided it probably wasn't a build error and just debugged, and thankfully
seem to have found the problem.  Apparently when building with MinGW under
Cygwin, compiler/cpp/main.cc is using the windows function GetFullPathName,
which returns a string full of backslashes.  All of the compiler code is
hardcoded to do rfind for forward-slashes, so it all breaks and produces
paths like "./gen-cpp/c:\temp\thrift\thrift\tutorial\shared_types.h" instead
of "./gen-cpp/shared_types.h".  Once I made main.cc:saferealpath replace '\'
with '/' the output worked fine.
Since I'd rather not go through the trouble of trying to set up code
contribution just to fix this minor bug, I'd appreciate it if someone who
works with this code regularly would add something akin to the following to
main.cc:194.5 just before "return resolved_path;":

size_t resolved_len = strlen(resolved_path);
for (size_t i = 0; i < resolved_len; ++i) {
  if (resolved_path[i] == '\\')
    resolved_path[i] = '/';
}

I'd also appreciate if the
http://wiki.apache.org/thrift/ThriftInstallationWin32 was updated to say
"after you build, get your non-cygwin-dependent .exe from the hidden '.libs'
directory", since it seems the thrift.exe in the local directory is merely a
cygwin1.dll-using pointer to that and this confused me for the longest time.

I tried sending this earlier with the binary attached, but my mail got
rejected so I assume it's because of the attachment.  If there's a place I
can upload the win32 binary for you all to host I'd be happy to do so.

-Mark

On Mon, Sep 14, 2009 at 11:38 PM, Bruce Simpson <bm...@incunabulum.net> wrote:

> Mark Schmit wrote:
>
>> Did this not go through or do people simply not build on (or care about
>> thrift compiler on) Windows?  Has anyone else encountered similar
>> problems?
>> -Mark
>>
>>
>
> Give MinGW + MSYS a try. It will not attempt to shim all of the POSIX APIs
> the way Cygwin does, but you might have better luck with it. The MSYS
> developer tools are needed to run configure scripts, and it has a GNU make.
>
> Have a look at the XORP BUILD_NOTES for step-by-step instructions on
> installing that stack of developer tools. We're not supporting Win32, for
> the moment, in XORP, due to a lack of active maintainership or current
> interest from Microsoft:-
>
> http://xorp.svn.sourceforge.net/viewvc/xorp/trunk/xorp/BUILD_NOTES?revision=11305&view=markup
>
> Scroll down to "Windows Server 2003".
>
> MinGW applications link directly against the Microsoft C Runtime,
> MSVCRT.DLL, shipped in all versions of Windows since Windows 98. One known
> issue with that DLL is that snprintf() has a very different return value
> from how it is implemented in the popular UNIX-like systems.
>
> If you need a Win32 Python, try the ActiveState build -- I have had better
> luck with it in the past. good luck!
>

Re: No C++ types output from Thrift compiler on Windows

Posted by Bruce Simpson <bm...@incunabulum.net>.
Mark Schmit wrote:
> Did this not go through or do people simply not build on (or care about
> thrift compiler on) Windows?  Has anyone else encountered similar problems?
> -Mark
>   

Give MinGW + MSYS a try. It will not attempt to shim all of the POSIX 
APIs the way Cygwin does, but you might have better luck with it. The 
MSYS developer tools are needed to run configure scripts, and it has a 
GNU make.

Have a look at the XORP BUILD_NOTES for step-by-step instructions on 
installing that stack of developer tools. We're not supporting Win32, 
for the moment, in XORP, due to a lack of active maintainership or 
current interest from Microsoft:-
 http://xorp.svn.sourceforge.net/viewvc/xorp/trunk/xorp/BUILD_NOTES?revision=11305&view=markup

Scroll down to "Windows Server 2003".

MinGW applications link directly against the Microsoft C Runtime, 
MSVCRT.DLL, shipped in all versions of Windows since Windows 98. One 
known issue with that DLL is that snprintf() has a very different return 
value from how it is implemented in the popular UNIX-like systems.

If you need a Win32 Python, try the ActiveState build -- I have had 
better luck with it in the past. good luck!

Re: No C++ types output from Thrift compiler on Windows

Posted by Rush Manbert <ru...@manbert.com>.
Sorry, but I can't help either. We only use the compiler on OS X. On  
Windows, all we care about are the C++ runtime libraries.

(And sorry for the delay, I've been on vacation.)

- Rush

On Sep 13, 2009, at 1:04 PM, Joel Meyer wrote:

> Mark, your message did go through. I believe most people are using  
> Thrift on
> *nix based platforms. A quick search of my GMail archives for the
> thrift-user list turned up some email from Rush Manbert referencing
> THRIFT-311 (https://issues.apache.org/jira/browse/THRIFT-311) for MSVC
> compatibility. That may be a good place to start looking. Sorry I  
> can't be
> more helpful.
> Cheers,
> Joel
>
> On Fri, Sep 11, 2009 at 10:03 PM, Mark Schmit <ms...@gmail.com>  
> wrote:
>
>> Did this not go through or do people simply not build on (or care  
>> about
>> thrift compiler on) Windows?  Has anyone else encountered similar  
>> problems?
>> -Mark
>>
>> On Mon, Sep 7, 2009 at 1:08 AM, Mark Schmit <ms...@gmail.com>  
>> wrote:
>>
>>> Hey guys,
>>> I'm new to Thrift but am looking forward to playing with it.
>> Unfortunately
>>> I'm struggling to get a working Thrift compiler on Windows.  I've  
>>> built
>>> thrift.exe in Cygwin with the no-cygwin-dependency path documented  
>>> on
>>> http://wiki.apache.org/thrift/ThriftInstallationWin32, but it  
>>> seems to
>>> only half-work.  For example, when I try to generate C++ code  
>>> using the
>>> tutorial files, the compiler says this:
>>>
>>> [ERROR:c:\development\project\foo\thrift\tutorial.thrift:123] (last
>>> token was 'shared.SharedService')
>>> Service "shared.SharedService" has not been defined.
>>>
>>> The same command line works fine on Linux.  Secondly, if I try  
>>> compiling
>>> shared.thrift directly, I only see SharedService.h/cpp and
>>> SharedService_server.skeleton.cpp, while on Linux I also see
>>> shared_types.h/cpp.  I tried some other sample .thrift files and  
>>> it seems
>>> like I'm missing all of the thrift-file-related (as opposed to
>>> service-related) C++ files.
>>>
>>> I tried generating Java and Python as well.  Java seemed to work
>> correctly,
>>> outputting the same thing on both Linux and Windows.  Python didn't
>> output
>>> *anything* on Windows, while it generated appropriate files and
>> directories
>>> on Linux.
>>>
>>> What's going on?  Did I build thrift.exe incorrectly?  Does  
>>> something
>> about
>>> it not like Windows?  Have others encountered similar problems?   
>>> (Any
>> chance
>>> of a binary distribution of thrift.exe so I can expect the compiled
>> binary
>>> to do what it's supposed to?)
>>>
>>> -Mark
>>>
>>


Re: No C++ types output from Thrift compiler on Windows

Posted by Joel Meyer <jo...@gmail.com>.
Mark, your message did go through. I believe most people are using Thrift on
*nix based platforms. A quick search of my GMail archives for the
thrift-user list turned up some email from Rush Manbert referencing
THRIFT-311 (https://issues.apache.org/jira/browse/THRIFT-311) for MSVC
compatibility. That may be a good place to start looking. Sorry I can't be
more helpful.
Cheers,
Joel

On Fri, Sep 11, 2009 at 10:03 PM, Mark Schmit <ms...@gmail.com> wrote:

> Did this not go through or do people simply not build on (or care about
> thrift compiler on) Windows?  Has anyone else encountered similar problems?
> -Mark
>
> On Mon, Sep 7, 2009 at 1:08 AM, Mark Schmit <ms...@gmail.com> wrote:
>
> > Hey guys,
> > I'm new to Thrift but am looking forward to playing with it.
>  Unfortunately
> > I'm struggling to get a working Thrift compiler on Windows.  I've built
> > thrift.exe in Cygwin with the no-cygwin-dependency path documented on
> > http://wiki.apache.org/thrift/ThriftInstallationWin32, but it seems to
> > only half-work.  For example, when I try to generate C++ code using the
> > tutorial files, the compiler says this:
> >
> > [ERROR:c:\development\project\foo\thrift\tutorial.thrift:123] (last
> > token was 'shared.SharedService')
> > Service "shared.SharedService" has not been defined.
> >
> > The same command line works fine on Linux.  Secondly, if I try compiling
> > shared.thrift directly, I only see SharedService.h/cpp and
> > SharedService_server.skeleton.cpp, while on Linux I also see
> > shared_types.h/cpp.  I tried some other sample .thrift files and it seems
> > like I'm missing all of the thrift-file-related (as opposed to
> > service-related) C++ files.
> >
> > I tried generating Java and Python as well.  Java seemed to work
> correctly,
> > outputting the same thing on both Linux and Windows.  Python didn't
> output
> > *anything* on Windows, while it generated appropriate files and
> directories
> > on Linux.
> >
> > What's going on?  Did I build thrift.exe incorrectly?  Does something
> about
> > it not like Windows?  Have others encountered similar problems?  (Any
> chance
> > of a binary distribution of thrift.exe so I can expect the compiled
> binary
> > to do what it's supposed to?)
> >
> > -Mark
> >
>

Re: No C++ types output from Thrift compiler on Windows

Posted by Mark Schmit <ms...@gmail.com>.
Did this not go through or do people simply not build on (or care about
thrift compiler on) Windows?  Has anyone else encountered similar problems?
-Mark

On Mon, Sep 7, 2009 at 1:08 AM, Mark Schmit <ms...@gmail.com> wrote:

> Hey guys,
> I'm new to Thrift but am looking forward to playing with it.  Unfortunately
> I'm struggling to get a working Thrift compiler on Windows.  I've built
> thrift.exe in Cygwin with the no-cygwin-dependency path documented on
> http://wiki.apache.org/thrift/ThriftInstallationWin32, but it seems to
> only half-work.  For example, when I try to generate C++ code using the
> tutorial files, the compiler says this:
>
> [ERROR:c:\development\project\foo\thrift\tutorial.thrift:123] (last
> token was 'shared.SharedService')
> Service "shared.SharedService" has not been defined.
>
> The same command line works fine on Linux.  Secondly, if I try compiling
> shared.thrift directly, I only see SharedService.h/cpp and
> SharedService_server.skeleton.cpp, while on Linux I also see
> shared_types.h/cpp.  I tried some other sample .thrift files and it seems
> like I'm missing all of the thrift-file-related (as opposed to
> service-related) C++ files.
>
> I tried generating Java and Python as well.  Java seemed to work correctly,
> outputting the same thing on both Linux and Windows.  Python didn't output
> *anything* on Windows, while it generated appropriate files and directories
> on Linux.
>
> What's going on?  Did I build thrift.exe incorrectly?  Does something about
> it not like Windows?  Have others encountered similar problems?  (Any chance
> of a binary distribution of thrift.exe so I can expect the compiled binary
> to do what it's supposed to?)
>
> -Mark
>