LisaFC | d1e11e7 | 2015-02-23 18:16:08 +0000 | [diff] [blame] | 1 | #gRPC in 3 minutes (C++) |
Abhishek Kumar | 3a5592c | 2015-02-20 15:32:42 -0800 | [diff] [blame] | 2 | |
LisaFC | d1e11e7 | 2015-02-23 18:16:08 +0000 | [diff] [blame] | 3 | ## Installation |
| 4 | |
| 5 | To install gRPC on your system, follow the instructions here: |
Abhishek Kumar | aa6c5fd | 2015-02-20 15:41:55 -0800 | [diff] [blame] | 6 | [https://github.com/grpc/grpc/blob/master/INSTALL](https://github.com/grpc/grpc/blob/master/INSTALL). |
Abhishek Kumar | 3a5592c | 2015-02-20 15:32:42 -0800 | [diff] [blame] | 7 | |
LisaFC | d1e11e7 | 2015-02-23 18:16:08 +0000 | [diff] [blame] | 8 | ## Hello C++ gRPC! |
Tim Emiola | 1013558 | 2015-02-23 09:22:26 -0800 | [diff] [blame] | 9 | |
LisaFC | d1e11e7 | 2015-02-23 18:16:08 +0000 | [diff] [blame] | 10 | Here's how to build and run the C++ implementation of the [Hello World](https://github.com/grpc/grpc-common/blob/master/protos/helloworld.proto) example used in [Getting started](https://github.com/grpc/grpc-common). |
Tim Emiola | 1013558 | 2015-02-23 09:22:26 -0800 | [diff] [blame] | 11 | |
| 12 | The example code for this and our other examples lives in the `grpc-common` |
| 13 | GitHub repository. Clone this repository to your local machine by running the |
| 14 | following command: |
| 15 | |
| 16 | |
| 17 | ```sh |
| 18 | $ git clone https://github.com/google/grpc-common.git |
| 19 | ``` |
| 20 | |
| 21 | Change your current directory to grpc-common/cpp/helloworld |
| 22 | |
| 23 | ```sh |
| 24 | $ cd grpc-common/cpp/helloworld/ |
| 25 | ``` |
| 26 | |
Tim Emiola | 1013558 | 2015-02-23 09:22:26 -0800 | [diff] [blame] | 27 | |
Tim Emiola | 1013558 | 2015-02-23 09:22:26 -0800 | [diff] [blame] | 28 | ### Generating gRPC code |
| 29 | |
Tim Emiola | 1013558 | 2015-02-23 09:22:26 -0800 | [diff] [blame] | 30 | To generate the client and server side interfaces: |
| 31 | |
| 32 | ```sh |
| 33 | $ make helloworld.pb.cc |
| 34 | ``` |
| 35 | Which internally invokes the proto-compiler as: |
| 36 | |
| 37 | ```sh |
Yang Gao | 3054eba | 2015-02-24 14:36:18 -0800 | [diff] [blame^] | 38 | $ protoc -I ../../protos/ --cpp_out=. --grpc_out=. --plugin=protoc-gen-grpc=grpc_cpp_plugin ../../protos/helloworld.proto |
Tim Emiola | 1013558 | 2015-02-23 09:22:26 -0800 | [diff] [blame] | 39 | ``` |
| 40 | |
LisaFC | d1e11e7 | 2015-02-23 18:16:08 +0000 | [diff] [blame] | 41 | ### Client and server implementations |
Tim Emiola | 1013558 | 2015-02-23 09:22:26 -0800 | [diff] [blame] | 42 | |
LisaFC | d1e11e7 | 2015-02-23 18:16:08 +0000 | [diff] [blame] | 43 | The client implementation is at [greeter_client.cc](https://github.com/grpc/grpc-common/blob/master/cpp/helloworld/greeter_client.cc). |
Tim Emiola | 1013558 | 2015-02-23 09:22:26 -0800 | [diff] [blame] | 44 | |
LisaFC | d1e11e7 | 2015-02-23 18:16:08 +0000 | [diff] [blame] | 45 | The server implementation is at [greeter_server.cc](https://github.com/grpc/grpc-common/blob/master/cpp/helloworld/greeter_server.cc). |
Tim Emiola | 1013558 | 2015-02-23 09:22:26 -0800 | [diff] [blame] | 46 | |
LisaFC | d1e11e7 | 2015-02-23 18:16:08 +0000 | [diff] [blame] | 47 | ### Try it! |
Yang Gao | 3054eba | 2015-02-24 14:36:18 -0800 | [diff] [blame^] | 48 | Build client and server: |
| 49 | ```sh |
| 50 | $ make |
| 51 | ``` |
| 52 | Run the server: |
| 53 | ```sh |
| 54 | $ ./greeter_server |
| 55 | ``` |
| 56 | Run the client: |
| 57 | ```sh |
| 58 | $ ./greeter_client |
| 59 | ``` |
LisaFC | d1e11e7 | 2015-02-23 18:16:08 +0000 | [diff] [blame] | 60 | |
| 61 | ## Tutorial |
| 62 | |
| 63 | You can find a more detailed tutorial in [gRPC Basics: C++](https://github.com/grpc/grpc-common/blob/master/cpp/cpptutorial.md) |