You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* C++ quick start: fix instructions
Closes#95Closes#97
* Post-review edits
* Reworked, and tested, instructions
* Updates based on Jan's feedback
* Updates following more feedback from Jan
Copy file name to clipboardExpand all lines: content/docs/quickstart/cpp.md
+174-68
Original file line number
Diff line number
Diff line change
@@ -3,69 +3,168 @@ layout: quickstart
3
3
title: C++ Quick Start
4
4
short: C++
5
5
description: This guide gets you started with gRPC in C++ with a simple working example.
6
+
cmake-version: 3.17.0
6
7
---
7
8
8
-
### Prerequisites
9
+
In the C++ world, there's no universally accepted standard for managing project
10
+
dependencies. In this quick start, you'll follow steps to build and locally
11
+
install gRPC before building and running this quick start's Hello World example.
12
+
13
+
### Setup
9
14
10
-
#### gRPC
15
+
Choose a directory to hold locally installed packages. This page assumes that
16
+
the environment variable `MY_INSTALL_DIR` holds this directory path. For
17
+
example:
11
18
12
-
To install gRPC on your system, follow the [instructions to install gRPC C++ via make](https://github.com/grpc/grpc/blob/master/src/cpp/README.md#make).
19
+
```sh
20
+
$ export MY_INSTALL_DIR=$HOME/local
21
+
```
13
22
14
-
To run the example code, please ensure `pkg-config` is installed on your
15
-
machine before you build and install gRPC in the previous step, since the
16
-
example `Makefile`s try to look up the installed gRPC path using `pkg-config`.
17
-
On Debian-based systems like Ubuntu, this can usually be done via
18
-
`sudo apt-get install pkg-config`.
23
+
Ensure that the directory exists:
19
24
20
-
#### Protocol Buffers v3
25
+
```sh
26
+
$ mkdir -p $MY_INSTALL_DIR
27
+
```
21
28
22
-
While not mandatory to use gRPC, gRPC applications usually leverage Protocol
23
-
Buffers v3 for service definitions and data serialization, and our example code
24
-
uses Protocol Buffers as well as gRPC. If you don't already have it installed on
25
-
your system, you can install the version cloned alongside gRPC. First ensure
26
-
that you are running these commands in the gRPC tree you just built in the from
27
-
the previous step.
29
+
Add the local `bin` folder to your path variable, for example:
28
30
29
31
```sh
30
-
$ cd third_party/protobuf
31
-
$ make && sudo make install
32
+
$ export PATH="$PATH:$MY_INSTALL_DIR/bin"
32
33
```
33
34
34
-
### Build the example
35
+
### Prerequisites
35
36
36
-
Always assuming you have gRPC properly installed, go into the example's
37
-
directory:
37
+
#### cmake
38
+
39
+
Version 3.13 or later of `cmake` is required to install gRPC locally.
40
+
41
+
- Linux
42
+
43
+
```sh
44
+
$ sudo apt install -y cmake
45
+
```
46
+
47
+
- macOS:
48
+
49
+
```sh
50
+
$ brew install cmake
51
+
```
52
+
53
+
- For general `cmake` installation instructions, see [Installing CMake][].
54
+
55
+
Check the version of `cmake`:
38
56
39
57
```sh
40
-
$ cd examples/cpp/helloworld/
58
+
$ cmake --version
41
59
```
42
60
43
-
Let's build the example client and server:
61
+
Under Linux, the version of the system-wide `cmake` can be too low. You can
62
+
install a more recent version into your local installation directory as follows:
0 commit comments