blob: ac4dea9b7fd091c1c2a9c09310545ff6410c8bf4 [file] [log] [blame] [view]
LisaFCd1e11e72015-02-23 18:16:08 +00001#gRPC in 3 minutes (C++)
Abhishek Kumar3a5592c2015-02-20 15:32:42 -08002
LisaFCd1e11e72015-02-23 18:16:08 +00003## Installation
4
5To install gRPC on your system, follow the instructions here:
Abhishek Kumaraa6c5fd2015-02-20 15:41:55 -08006[https://github.com/grpc/grpc/blob/master/INSTALL](https://github.com/grpc/grpc/blob/master/INSTALL).
Abhishek Kumar3a5592c2015-02-20 15:32:42 -08007
LisaFCd1e11e72015-02-23 18:16:08 +00008## Hello C++ gRPC!
Tim Emiola10135582015-02-23 09:22:26 -08009
LisaFCd1e11e72015-02-23 18:16:08 +000010Here'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 Emiola10135582015-02-23 09:22:26 -080011
12The example code for this and our other examples lives in the `grpc-common`
13GitHub repository. Clone this repository to your local machine by running the
14following command:
15
16
17```sh
18$ git clone https://github.com/google/grpc-common.git
19```
20
21Change your current directory to grpc-common/cpp/helloworld
22
23```sh
24$ cd grpc-common/cpp/helloworld/
25```
26
Tim Emiola10135582015-02-23 09:22:26 -080027
Tim Emiola10135582015-02-23 09:22:26 -080028### Generating gRPC code
29
Tim Emiola10135582015-02-23 09:22:26 -080030To generate the client and server side interfaces:
31
32```sh
33$ make helloworld.pb.cc
34```
35Which internally invokes the proto-compiler as:
36
37```sh
Yang Gao3054eba2015-02-24 14:36:18 -080038$ protoc -I ../../protos/ --cpp_out=. --grpc_out=. --plugin=protoc-gen-grpc=grpc_cpp_plugin ../../protos/helloworld.proto
Tim Emiola10135582015-02-23 09:22:26 -080039```
40
LisaFCd1e11e72015-02-23 18:16:08 +000041### Client and server implementations
Tim Emiola10135582015-02-23 09:22:26 -080042
LisaFCd1e11e72015-02-23 18:16:08 +000043The client implementation is at [greeter_client.cc](https://github.com/grpc/grpc-common/blob/master/cpp/helloworld/greeter_client.cc).
Tim Emiola10135582015-02-23 09:22:26 -080044
LisaFCd1e11e72015-02-23 18:16:08 +000045The server implementation is at [greeter_server.cc](https://github.com/grpc/grpc-common/blob/master/cpp/helloworld/greeter_server.cc).
Tim Emiola10135582015-02-23 09:22:26 -080046
LisaFCd1e11e72015-02-23 18:16:08 +000047### Try it!
Yang Gao3054eba2015-02-24 14:36:18 -080048Build client and server:
49```sh
50$ make
51```
52Run the server:
53```sh
54$ ./greeter_server
55```
56Run the client:
57```sh
58$ ./greeter_client
59```
LisaFCd1e11e72015-02-23 18:16:08 +000060
61## Tutorial
62
63You can find a more detailed tutorial in [gRPC Basics: C++](https://github.com/grpc/grpc-common/blob/master/cpp/cpptutorial.md)