Thrift
  1. Thrift
  2. THRIFT-757

Thrift (CPP) library, compiler, and the example built and working successfully on Cygwin.

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 0.3
    • Fix Version/s: None
    • Component/s: C++ - Compiler
    • Labels:
      None
    • Environment:

      Cygwin (win32)

    • Patch Info:
      Patch Available

      Description

      I managed to get Thrift (CPP) library, compiler, and the example built and working successfully on Cygwin. Note that I only tested with CPP (although I saw 'libthrift.jar' was built as well).

      1. ASF.LICENSE.NOT.GRANTED--Thrift.cpp
        3 kB
        Steven Ong
      2. ASF.LICENSE.NOT.GRANTED--Makefile
        1 kB
        Steven Ong
      3. ASF.LICENSE.NOT.GRANTED--buildCygwin.sh
        0.3 kB
        Steven Ong
      4. ASF.LICENSE.NOT.GRANTED--buildNexenta.sh
        0.2 kB
        Steven Ong

        Activity

        Hide
        Roger Meier added a comment -

        please rebase this to trunk or use VisualStudio to build thrift on windows

        Show
        Roger Meier added a comment - please rebase this to trunk or use VisualStudio to build thrift on windows
        Hide
        Dheeraj Goswami added a comment - - edited

        Hi Steven,
        This patch that you built using cygwin, can it work with Visual studio tool chain. I have my base/master project using Visual studio tool chain and I need to use thrift (CPP) can you suggest some solution for this?

        thanks
        dheeraj

        Show
        Dheeraj Goswami added a comment - - edited Hi Steven, This patch that you built using cygwin, can it work with Visual studio tool chain. I have my base/master project using Visual studio tool chain and I need to use thrift (CPP) can you suggest some solution for this? thanks dheeraj
        Hide
        Bryan Duxbury added a comment -

        I'm deprioritizing, unless any other committer with more understanding of what to do wants to take care of this one.

        Show
        Bryan Duxbury added a comment - I'm deprioritizing, unless any other committer with more understanding of what to do wants to take care of this one.
        Hide
        Bryan Duxbury added a comment -

        Steven - I understand you already attached all the files, but it's much easier for committers to deal with a single patch file, since then I only have to keep track of one download, and all I have to do is run "patch -p0 < patchfile" to get stuff in place.

        Show
        Bryan Duxbury added a comment - Steven - I understand you already attached all the files, but it's much easier for committers to deal with a single patch file, since then I only have to keep track of one download, and all I have to do is run "patch -p0 < patchfile" to get stuff in place.
        Hide
        Steven Ong added a comment -

        Hi,

        First of all, I am away from my PC and will not get back until at least
        tonight. However...

        I did attached the files you need along with the JIRA I opned. All you need
        to do is diff/merge this file with the current file:
        Thrift.cpp

        ... and replace the "Makefile" in the 'example' directory with the one that
        I attached (You can run a 'diff' and see what's changed).

        Again, all the files you need had already attached in the JIRA.

        Please let me know if I can be further help.

        Thanks,
        Steven

        Show
        Steven Ong added a comment - Hi, First of all, I am away from my PC and will not get back until at least tonight. However... I did attached the files you need along with the JIRA I opned. All you need to do is diff/merge this file with the current file: Thrift.cpp ... and replace the "Makefile" in the 'example' directory with the one that I attached (You can run a 'diff' and see what's changed). Again, all the files you need had already attached in the JIRA. Please let me know if I can be further help. Thanks, Steven
        Hide
        Bryan Duxbury added a comment -

        Can you attach these files as a patch? I'm just not sure where I'm supposed to put them.

        If you get back to me today, I'll include this in 0.3. Otherwise, it'll have to be in 0.4.

        Show
        Bryan Duxbury added a comment - Can you attach these files as a patch? I'm just not sure where I'm supposed to put them. If you get back to me today, I'll include this in 0.3. Otherwise, it'll have to be in 0.4.
        Hide
        Steven Ong added a comment -

        buildCygwin.sh:

        • a little script I wrote to configure/compile/install on Cygwin

        buildNexenta.sh:

        • a little script I wrote to configure/compile/install on Nexenta
            • Feel free to change them for your own use.
        Show
        Steven Ong added a comment - buildCygwin.sh: a little script I wrote to configure/compile/install on Cygwin buildNexenta.sh: a little script I wrote to configure/compile/install on Nexenta Feel free to change them for your own use.
        Hide
        Steven Ong added a comment -

        Changes in Thrift.cpp:

        $ diff /cygdrive/z/thrift-0.2.0/lib/cpp/src/Thrift.cpp ./Thrift.cpp
        23d22
        < #include <protocol/TProtocol.h>
        25c24,36
        < #include <stdio.h>

        > //#include <stdio.h>
        >
        > #if defined(_CYGWIN) && defined(_cplusplus)
        > #include <cstdlib>
        > #include <cstdio>
        > #else
        > #include <stdlib.h>
        > #include <stdio.h>
        > #endif
        >
        >

          • Right after :
            namespace apache { namespace thrift {
            .......
            >
            28a40,43
            > #if defined(_CYGWIN) && defined(_cplusplus)
            > using namespace std;
            > #endif

        ... There are 2 issues here as far as Cygwin is concerning:
        1. Missing the inclusion of "stdlib", hence, "malloc" not found

        2. Even after I added the "stdlib" inclusion, "mallloc" still not found since I included "stdlib.h" and "malloc" was used inside "namespace apache". So I change for it to use "cstdlib" (and "cstdio") instead, but then I have to declare "using namespace std;" inside the "namespace apache". Just to prevent it may cause some side-effect in some other platform, I put the "#if defined(_CYGWIN) && defined(_cplusplus)" wherever the changes are.
        Also, I've tested on Nexenta. Look like it OK.

        ****************
        Changes I've made to the ~/tutorial/cpp/Makefile:

        $ diff /cygdrive/z/thrift-0.2.0/tutorial/cpp/Makefile ./Makefile
        20,22d19
        < BOOST_DIR = /usr/local/boost/include/boost-1_33_1/
        < THRIFT_DIR = /usr/local/include/thrift
        < LIB_DIR = /usr/local/lib
        24c21,23
        < GEN_SRC = ../gen-cpp/SharedService.cpp ../gen-cpp/shared_types.cpp ../gen-cpp/tutori al_types.cpp ../gen-cpp/Calculator.cpp

        > # Change to the actual directory if need to
        > THRIFT_DIR = /opt/thrift
        > GEN_CPP = ../gen-cpp
        26c25,27
        < default: server client

        > INCL = -I/opt/boostLib/boostS_1_41/include
        > INCL += -I$(THRIFT_DIR)/include/thrift
        > INCL += -I$(GEN_CPP)
        28,29c29,30
        < server: CppServer.cpp
        < g++ -o CppServer -I$

        {THRIFT_DIR} -I${BOOST_DIR} -I../gen-cpp -L${LIB_DIR} -lt hrift CppServer.cpp ${GEN_SRC}

        > LIBS = -L$(THRIFT_DIR)/lib
        > LIBS += -lthrift
        31,32c32,43
        < client: CppClient.cpp
        < g++ -o CppClient -I${THRIFT_DIR}

        -I$

        {BOOST_DIR}

        -I../gen-cpp -L$

        {LIB_DIR}

        -lt hrift CppClient.cpp $

        {GEN_SRC}


        > PROG = CppServer CppClient
        >
        > GEN_SRC = $(GEN_CPP)/SharedService.cpp
        > GEN_SRC += $(GEN_CPP)/shared_types.cpp
        > GEN_SRC += $(GEN_CPP)/tutorial_types.cpp
        > GEN_SRC += $(GEN_CPP)/Calculator.cpp
        >
        > all: $(PROG)
        >
        > $(PROG):
        > @echo Compiling $@
        > g++ $(INCL) $@.cpp $(GEN_SRC) $(LIBS) -o $@
        35c46,54
        < $(RM) -r CppClient CppServer

        > $(RM) -r $(PROG) *.o *.exe *~
        >
        > clean_clober: clean
        > cd ../
        > rm -rf gen-cpp
        >
        > generate:
        > cd ../; $(THRIFT_DIR)/bin/thrift -r --gen cpp tutorial.thrift
        >

        • The previous Makefile was badly written. Plus Cygwin is more picky about Makefile, hence, the change. I've also tested this Makefile on Nexenta and it worked.
        Show
        Steven Ong added a comment - Changes in Thrift.cpp: $ diff /cygdrive/z/thrift-0.2.0/lib/cpp/src/Thrift.cpp ./Thrift.cpp 23d22 < #include <protocol/TProtocol.h> 25c24,36 < #include <stdio.h> — > //#include <stdio.h> > > #if defined(_ CYGWIN ) && defined( _cplusplus) > #include <cstdlib> > #include <cstdio> > #else > #include <stdlib.h> > #include <stdio.h> > #endif > > Right after : namespace apache { namespace thrift { ....... > 28a40,43 > #if defined(_ CYGWIN ) && defined( _cplusplus) > using namespace std; > #endif ... There are 2 issues here as far as Cygwin is concerning: 1. Missing the inclusion of "stdlib", hence, "malloc" not found 2. Even after I added the "stdlib" inclusion, "mallloc" still not found since I included "stdlib.h" and "malloc" was used inside "namespace apache". So I change for it to use "cstdlib" (and "cstdio") instead, but then I have to declare "using namespace std;" inside the "namespace apache". Just to prevent it may cause some side-effect in some other platform, I put the "#if defined(_ CYGWIN ) && defined( _cplusplus)" wherever the changes are. Also, I've tested on Nexenta. Look like it OK. **************** Changes I've made to the ~/tutorial/cpp/Makefile: $ diff /cygdrive/z/thrift-0.2.0/tutorial/cpp/Makefile ./Makefile 20,22d19 < BOOST_DIR = /usr/local/boost/include/boost-1_33_1/ < THRIFT_DIR = /usr/local/include/thrift < LIB_DIR = /usr/local/lib 24c21,23 < GEN_SRC = ../gen-cpp/SharedService.cpp ../gen-cpp/shared_types.cpp ../gen-cpp/tutori al_types.cpp ../gen-cpp/Calculator.cpp — > # Change to the actual directory if need to > THRIFT_DIR = /opt/thrift > GEN_CPP = ../gen-cpp 26c25,27 < default: server client — > INCL = -I/opt/boostLib/boostS_1_41/include > INCL += -I$(THRIFT_DIR)/include/thrift > INCL += -I$(GEN_CPP) 28,29c29,30 < server: CppServer.cpp < g++ -o CppServer -I$ {THRIFT_DIR} -I${BOOST_DIR} -I../gen-cpp -L${LIB_DIR} -lt hrift CppServer.cpp ${GEN_SRC} — > LIBS = -L$(THRIFT_DIR)/lib > LIBS += -lthrift 31,32c32,43 < client: CppClient.cpp < g++ -o CppClient -I${THRIFT_DIR} -I$ {BOOST_DIR} -I../gen-cpp -L$ {LIB_DIR} -lt hrift CppClient.cpp $ {GEN_SRC} — > PROG = CppServer CppClient > > GEN_SRC = $(GEN_CPP)/SharedService.cpp > GEN_SRC += $(GEN_CPP)/shared_types.cpp > GEN_SRC += $(GEN_CPP)/tutorial_types.cpp > GEN_SRC += $(GEN_CPP)/Calculator.cpp > > all: $(PROG) > > $(PROG): > @echo Compiling $@ > g++ $(INCL) $@.cpp $(GEN_SRC) $(LIBS) -o $@ 35c46,54 < $(RM) -r CppClient CppServer — > $(RM) -r $(PROG) *.o *.exe *~ > > clean_clober: clean > cd ../ > rm -rf gen-cpp > > generate: > cd ../; $(THRIFT_DIR)/bin/thrift -r --gen cpp tutorial.thrift > The previous Makefile was badly written. Plus Cygwin is more picky about Makefile, hence, the change. I've also tested this Makefile on Nexenta and it worked.

          People

          • Assignee:
            Unassigned
            Reporter:
            Steven Ong
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 24h
              24h
              Remaining:
              Remaining Estimate - 24h
              24h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development