---
# System prepended metadata

title: Protobuf

---

Protobuf
===

installation
---
    git clone -b v3.20.0 https://github.com/protocolbuffers/protobuf.git
    git submodule update --init --recursive

JavaScript
===
    
    $ npm install @grpc/grpc-js
    
    $ npm install -g protoc-gen-js
gRPC
===

installation
---
    $ export GRPC_INSTALL_DIR=$HOME/.local
    $ mkdir -p $GRPC_INSTALL_DIR
    $ export PATH="$GRPC_INSTALL_DIR/bin:$PATH"
    $ git clone --recurse-submodules -b v1.55.0 --depth 1 --shallow-submodules https://github.com/grpc/grpc
    $ cd grpc
    $ mkdir -p cmake/build
    $ pushd cmake/build
    $ cmake -DgRPC_INSTALL=ON \
          -DgRPC_BUILD_TESTS=OFF \
          -DCMAKE_INSTALL_PREFIX=$GRPC_INSTALL_DIR \
          ../..
    $ make -j4
    $ make install
    $ popd
    
user compile guide
---
    # Go to your work space
    $ export GRPC_INSTALL_DIR=$HOME/.local
    $ export PATH="$GRPC_INSTALL_DIR/bin:$PATH"
    # assume now you write your own project
    $ mkdir -p cmake/build
    $ pushd cmake/build
    $ cmake ../.. -DCMAKE_PREFIX_PATH="$GRPC_INSTALL_DIR"
    $ make

On Sbrio
---
    # install abseil
    $ export GRPC_INSTALL_DIR=$HOME/.grpc_local
    $ mkdir -p $GRPC_INSTALL_DIR
    $ export PATH="$GRPC_INSTALL_DIR/bin:$PATH"
    $ mkdir -p "third_party/abseil-cpp/cmake/build"
    $ pushd "third_party/abseil-cpp/cmake/build"
    $ cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE ../.. -DABSL_PROPAGATE_CXX_STD=ON -DCMAKE_INSTALL_PREFIX=$GRPC_INSTALL_DIR
    $ make install
    $ popd
    
    
    # install cares
    $ mkdir -p "third_party/cares/cares/cmake/build"
    $ pushd "third_party/cares/cares/cmake/build"
    $ cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE ../.. -DCMAKE_INSTALL_PREFIX=$GRPC_INSTALL_DIR
    $ make install
    $ popd
    
    # install protobuf
    $ mkdir -p "third_party/protobuf/cmake/build"
    $ pushd "third_party/protobuf/cmake/build"
    $ cmake -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -Dprotobuf_ABSL_PROVIDER=package ../.. -DCMAKE_INSTALL_PREFIX=$GRPC_INSTALL_DIR
    $ make install
    $ popd

    # install re2
    $ mkdir -p "third_party/re2/cmake/build"
    $ pushd "third_party/re2/cmake/build"
    $ cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE ../.. -DCMAKE_INSTALL_PREFIX=$GRPC_INSTALL_DIR
    $ make install
    $ popd
    
    # install zlib
    $ mkdir -p "third_party/zlib/cmake/build"
    $ pushd "third_party/zlib/cmake/build"
    $ cmake -DCMAKE_BUILD_TYPE=Release ../.. -DCMAKE_INSTALL_PREFIX=$GRPC_INSTALL_DIR
    $ make install
    $ popd
    
if your environment cannot install openssl normally, then you can build the boringssl-with-bazel. And copy src/include and your library and binary to workspace.
    
    $ mkdir -p cmake/build
    $ cmake \                          
      -DCMAKE_BUILD_TYPE=Release \
      -DgRPC_INSTALL=ON \
      -DgRPC_BUILD_TESTS=OFF \
      -DgRPC_CARES_PROVIDER=package \
      -DgRPC_ABSL_PROVIDER=package \
      -DgRPC_PROTOBUF_PROVIDER=package \
      -DgRPC_RE2_PROVIDER=package \
      -DgRPC_SSL_PROVIDER=package \
      -DgRPC_ZLIB_PROVIDER=package \
      -DCMAKE_INSTALL_PREFIX=$GRPC_INSTALL_DIR \
      -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl \
      ../..
    