Dear Wiki user, You have subscribed to a wiki page or wiki category on "Thrift Wiki" for change notification.
The "ThriftUsageC++" page has been changed by AkiraKitada. http://wiki.apache.org/thrift/ThriftUsageC%2B%2B?action=diff&rev1=23&rev2=24 -------------------------------------------------- 1. Run {{{ make install}}} to install the library. Your user needs root permissions. == Generating the server code == - In this example we use an imaginary file called {{{your-thrift-file.thrift}}}: + In this example we use an imaginary file called {{{your_thrift_file.thrift}}}: {{{#!text #!/usr/local/bin/thrift --gen cpp @@ -33, +33 @@ Now run: {{{ - thrift --gen cpp your-thrift-file.thrift + thrift --gen cpp your_thrift_file.thrift }}} === Exploring the generated code - The Server === The generated code should be under the {{{gen-cpp}}} directory. You will see a number of generated C++ and header files along with an automatically generated server skeleton code (in bold). @@ -41, +41 @@ * Something.cpp * Something.h * '''Something_server.skeleton.cpp''' - * your-thrift-file_constants.cpp + * your_thrift_file_constants.cpp - * your-thrift-file_constants.h + * your_thrift_file_constants.h - * your-thrift-file_types.cpp + * your_thrift_file_types.cpp - * your-thrift-file_types.h + * your_thrift_file_types.h === Implementing the Server === Copy the generated server skeleton to a file named Something_server.cpp and keep the original: @@ -110, +110 @@ {{{ g++ -Wall -I/usr/local/include/thrift -c Something.cpp -o something.o g++ -Wall -I/usr/local/include/thrift -c Something_server.cpp -o server.o - g++ -Wall -I/usr/local/include/thrift -c your-thrift-file_constants.cpp -o constants.o + g++ -Wall -I/usr/local/include/thrift -c your_thrift_file_constants.cpp -o constants.o - g++ -Wall -I/usr/local/include/thrift -c your-thrift-file_types.cpp -o types.o + g++ -Wall -I/usr/local/include/thrift -c your_thrift_file_types.cpp -o types.o }}} === Linking === You need to point your linker to the thrift library. (Linker flag: {{{ -lthrift }}} or {{{ -l/usr/local/lib/libthrift.so }}}
