Created
October 18, 2021 18:21
-
-
Save andrew-ma/dd580a32b90a2c188abfeb3a7b189857 to your computer and use it in GitHub Desktop.
GRPC Install Instructions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Can modify this to change the directory where are final outputs are installed to | |
export MY_INSTALL_DIR=$HOME/Desktop/GRPC_INSTALL | |
mkdir -p $MY_INSTALL_DIR | |
# Add the $MY_INSTALL_DIR/bin folder to path | |
# because it contains the protoc and protoc language specific plugin executables | |
export PATH="$MY_INSTALL_DIR/bin:$PATH" | |
# Install required build tools | |
sudo apt install -y cmake build-essential autoconf libtool pkg-config | |
# Clone the grpc repo and submodules | |
git clone --recurse-submodules -b v1.41.0 https://github.com/grpc/grpc | |
# Build and install the grpc repo | |
cd grpc | |
# Create a new subdirectory 'build' inside the 'grpc' directory | |
# where we will use CMAKE to generate our Makefiles | |
# But first, remove the old CMAKE generated makefiles | |
rm -rf build | |
mkdir build | |
pushd build | |
# Run CMAKE to generate the Makefiles | |
cmake -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=$MY_INSTALL_DIR .. | |
# Run the generated Makefile, to compile the code | |
make -j4 | |
# Run the Makefile install target | |
# But first, remove the old files that were previously installed | |
rm -rf $MY_INSTALL_DIR | |
mkdir -p $MY_INSTALL_DIR | |
# The Makefile install target will generate the files to wherever we set our -DCMAKE_INSTALL_PREFIX=$MY_INSTALL_DIR | |
make install | |
# Return to the 'grpc' folder | |
popd | |
# List our INSTALLED files | |
ls $MY_INSTALL_DIR | |
# Since we added our $MY_INSTALL_DIR/bin to the PATH, we should be able to access the 'protoc' executable | |
which protoc | |
which grpc_cpp_plugin | |
# Symlink our local installed library files ($MY_INSTALL_DIR/lib) to /usr/local/lib, so they can be found by CMAKE | |
sudo mkdir -p /usr/local/lib/grpc | |
sudo ln -s $MY_INSTALL_DIR/lib/* /usr/local/lib | |
# Symlink our local installed header files ($MY_INSTALL_DIR/include) to /usr/local/include, so they can be found by CMAKE | |
sudo ln -s $MY_INSTALL_DIR/include/* /usr/local/include | |
# Symlink our local installed executable files ($MY_INSTALL_DIR/bin) to /usr/local/bin, so they can be automatically added to PATH | |
sudo ln -s $MY_INSTALL_DIR/bin/* /usr/local/bin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment