Skip to content

Instantly share code, notes, and snippets.

@hhhaiai
Last active December 26, 2022 07:21
Show Gist options
  • Save hhhaiai/5a6304d252c8af68e749289a76115a62 to your computer and use it in GitHub Desktop.
Save hhhaiai/5a6304d252c8af68e749289a76115a62 to your computer and use it in GitHub Desktop.
Install gRPC++ on Ubuntu20.04

Solved step

# install dependencies,it's easy here
sudo apt install -y cmake
# install basic tools
sudo apt install -y build-essential autoconf libtool pkg-config

# clone from github and install it,I installed v1.51.1 here
git clone --recurse-submodules -b v1.51.1 https://github.com/grpc/grpc
cd grpc

# use Bazel to build
# Failed to use cmake build at last time

# install Bazel
sudo apt install curl gnupg
curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel.gpg
sudo mv bazel.gpg /etc/apt/trusted.gpg.d/
echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" \
| sudo tee /etc/apt/sources.list.d/bazel.list
sudo apt update && sudo apt install bazel
sudo apt update && sudo apt full-upgrade
sudo apt install openjdk-11-jdk

# Build gRPC
bazel build :all
bazel test --config=dbg //test/...

# Install
cmake -DgRPC_INSTALL=ON \ ./

make 
make install 

After finishing the followings,how to make sure gRPC is installed successfully? Just run the example given by the reprosity. In example/cpp/helloworld/ path,you just to do this:

mkdir -p cmake/build
pushd cmake/build
cmake -DCMAKE_PREFIX_PATH=$MY_INSTALL_DIR ../..
make -j

And then do:

./greeter_server
./greeter_client

And I can make sure gRPC is installed now.

Records of hitting the wall

I started to install gRPC since yesterday and I have done it now. It costs me two full day to install it.
I looked up some blogs and pages which guide to install gRPC:

Some helped me,but some disturbed me a lot:(

Failed to install g++

It's unblievable that in ubuntu I cannot install g++ which is a so bisic library. But it happened. It caused when I change my ubuntu /etc/apt/sources.list,I do sudo apt update but I forgot to run sudo apt upgrade,so it cannot install g++

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment