Hi Randy,

The one thing to remember is that I'm not building for a Windows target, I'm building for a Linux target using a cross-compiler running on Windows. So, I'm not sure how to handle some of the config values, since I don't really know what the cross compiler supports.

That said, I did include the stock config file generated by ./configure on Ubuntu and the project as a whole did actually build. Hopefully a lot of those config items are correct or unused in such a simple implementation of the Thrift C++ server.
======
Chris Seto
http://www.chrisseto.com
======
On 6/23/2015 1:55 PM, Randy Abernethy wrote:
Hey Chris,

Yes, configure gens the config.h on *.nix.

thrift@ubuntu:~/thrift$ head config.h
      /* config.h.  Generated from config.hin by configure.  */
      /* config.hin.  Generated from configure.ac by autoheader.  */


      #ifndef CONFIG_H
      #define CONFIG_H


      /* Define if the AI_ADDRCONFIG symbol is unavailable */
      /* #undef AI_ADDRCONFIG */


On Windows there is a static config.h which should be used (you will
suffer mightily if you try to use a Linux config on Windows [not that I
have, er, tried...]):

thrift@ubuntu:~/thrift$ tail lib/cpp/src/thrift/windows/config.h
     // windows
      #include <Winsock2.h>
      #include <ws2tcpip.h>
      #ifdef _WIN32_WCE
      #pragma comment(lib, "Ws2.lib")
      #else
      #pragma comment(lib, "Ws2_32.lib")
      #pragma comment(lib, "advapi32.lib") // For security APIs in
TPipeServer
      #endif
      #endif // _THRIFT_WINDOWS_CONFIG_H_

The above config should be included when _WIN32 is defined per below:

thrift@ubuntu:~/thrift$ tail -5 lib/cpp/src/thrift/thrift-config.h
      #ifdef _WIN32
      #include <thrift/windows/config.h>
      #else
      #include <thrift/config.h>
      #endif

...and the whole thing starts here:

thrift@ubuntu:~/thrift$ head -29 lib/cpp/src/thrift/Thrift.h | tail
      #ifndef _THRIFT_THRIFT_H_
      #define _THRIFT_THRIFT_H_ 1

      #include <thrift/transport/PlatformSocket.h>

      #include <thrift/thrift-config.h>

      #include <stdio.h>
      #include <assert.h>

Further, be advised that there is a Visual Studio solution for libthrift
and libthriftnb here:
thrift@ubuntu:~/thrift$ ls -l lib/cpp/*.sln
-rw-rw-r-- 1 thrift thrift 3625 Jun 22 14:41 lib/cpp/thrift.sln

This solution is a good place to figure out what you might need to be
building (and
not bad for building the libs/dlls should you change tack).

The thrift build system is slowly migrating to cmake, which is particularly
Windows friendly. This:

thrift@ubuntu:~/thrift$ cmake .
...
thrift@ubuntu:~/thrift$ make
...

will build the compiler and C++ libs on Linux. Do not think cmake is
tweaked to
run on Windows directly yet though. Roger has posted some nice notes here:
https://github.com/apache/thrift/blob/1568aef7d499153469131449ec682998598f0d3c/build/cmake/README.md

Also there is a pre built thrift compiler for Windows here:
https://thrift.apache.org/download

Hope this helps,
Randy

P.S. I am faking this until someone who knows what they're talking about,
like Roger or Jake, steps in...


On Tue, Jun 23, 2015 at 1:15 PM, Chris Seto <[email protected]> wrote:

Hi Randy,

Thanks, this is exactly the information I needed. For clarification, it
looks like I obviously need the directory: thrift-0.9.2\lib\cpp\src\thrift
, though is there anything else that might be more obscure?

The second question I have is in regards to the config.h file. This file
is included by thrift-0.9.2\lib\cpp\src\thrift\thrift-config.h, and it is
not normally present in the source tree. It looks like it's probably a
product of ./configure. What's the best way to get this file? Should I
simply ./configure on my Linux target, then copy the file over and edit, or
is there a better way?

Otherwise, the process seems fairly typical. The config file was the big
catch when I tried to include boiler plate files off the bat.

Also, thanks Jens as well. I looked through the tutorials quite a bit, but
the issue was that they don't talk a lot about including the Thrift library
files into your project, only about using the IDL format.

======
Chris Seto
http://www.chrisseto.com
======

On 6/23/2015 12:51 PM, Randy Abernethy wrote:

Hi Chris,

I often build Thrift C++ apps on Windows without precompiled libs. The
first time I did it I just added the obvious cpp files from the thrift cpp
lib to my project, built, read through the linker errors, grepped around,
added some more cpp files, and so on. It is pretty easy to pull together
the necessary cpp source for a client, a bit more work for a server but
certainly doable. You learn a lot in the process too. Once you have the
boilerplate list of files you generally depend on it is pretty routine.
Makes debugging easy too, no need to configure debug and release libs,
never any problems with the IDE figuring out where the source is when you
want to step into code, etc. I also found building some dependencies on
windows rough, in particular libevent. It was much easier to just compile
the bits of lib event I needed without trying to make the entire thing
work.

At the end of the day I use static libs most of the time but just want to
let you know that compiling the Thrift sources into your executable
directly is no big hardship on any platform.

Best,
Randy

On Tue, Jun 23, 2015 at 11:04 AM, Chris Seto <[email protected]>
wrote:

  Hi all,
I am a beginner to the Thrift framework, and I'm looking into using
Thrift
on a project which is half embedded (actually C++ on embedded Linux) and
half C#. Obviously the C# side is standard affair, so I'm not worried
about
it at all.

On the embedded side, I am running a little embedded Linux computer
running Angstrom Linux. While I can build either natively or on a desktop
Linux target, I actually have been cross compiling my application on my
Windows machine With the GCC-Linaro toolchain.

Obviously, I can run the thrift compiler on my Windows machine, so
generating the subs isn't a big deal.

I'm more wondering how to include the Thrift libraries in the project. I
do have an Ubuntu Linux machine which has Thrift "installed", but what
exactly is the Thrift installation doing, and what is the best way to
include Thrift into my existing C++ project? Is there a clean way that I
could compile Thrift libs on my Ubuntu machine, then link against them on
my Windows build environment? Similarly, would it be possible for me to
simply include the libs as source files in my existing C++ project?

Thanks
--



Reply via email to