Dear Wiki user, You have subscribed to a wiki page or wiki category on "Thrift Wiki" for change notification.
The following page has been changed by HannesBaldursson: http://wiki.apache.org/thrift/ThriftUsageC++ The comment on the change is: Basic server tutorial ------------------------------------------------------------------------------ = Getting started = - The C++ code generated by Thrift compiles only on Unix based systems. + The first thing you need to know is that the C++ code generated by Thrift compiles only on Unix based systems. == Requirements == Make sure that your system meets the requirements as noted in ThriftRequirements @@ -13, +13 @@ 1. Run {{{ make}}} to compile 1. Run {{{ make install}}} to install the library. Your user needs root permissions. + == Generating the code == + + In this example we use an imaginary file called {{{your-thrift-file.thrift}}}: + {{{ + #!/usr/local/bin/thrift --gen cpp + + namespace cpp Test + + service Something { + i32 ping() + } + }}} + + Now run: + {{{ + 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 skeleton code for your server (in bold). + + * Something.cpp + * Something.h + * '''Something_server.skeleton.cpp''' + * your-thrift-file_constants.cpp + * your-thrift-file_constants.h + * your-thrift-file_types.cpp + * your-thrift-file_types.h + + === Writing the Server === + + Make a copy of the generated skeleton server to a file named Something_server.cpp: + {{{ + cp Something_server.skeleton.cpp Something_server.cpp + }}} +
