[ 
https://issues.apache.org/jira/browse/THRIFT-757?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Steven Ong updated THRIFT-757:
------------------------------

    Attachment: Thrift.cpp
                Makefile

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








> Thrift (CPP) library, compiler, and the example built and working 
> successfully on Cygwin.
> -----------------------------------------------------------------------------------------
>
>                 Key: THRIFT-757
>                 URL: https://issues.apache.org/jira/browse/THRIFT-757
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (C++)
>    Affects Versions: 0.3
>         Environment: Cygwin (win32)
>            Reporter: Steven Ong
>             Fix For: 0.3
>
>         Attachments: Makefile, Thrift.cpp
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> 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).

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to