grpc install
macos11.4下 grpc-cpp安装
lib
brew install autoconf automake libtool shtool gflags cmake pkg-config
grpc-cpp
git clone https://github.com/grpc/grpc.git
git checkout -b v1.38.x
# 下载所有子模块
git submodule update --init --recursive
protobuf3 install
git clone https://github.com/google/protobuf.git
cd protobuf
git checkout v3.9.0
sh ./autogen.sh
./configure --prefix=/usr/local/protobuf/
make
sudo make install
查看版本
cd /usr/local/protobuf/bin/
./protoc --version
将下面指令加入.bash_profiile中之后执行source ~/.bash_profile
export PATH=$PATH:/usr/local/protobuf/bin/
grpc install
cd grpc
export MY_INSTALL_DIR=$HOME/.local
mkdir -p $MY_INSTALL_DIR
export PATH="$MY_INSTALL_DIR/bin:$PATH"
mkdir -p cmake/build
pushd cmake/build
cmake -DgRPC_INSTALL=ON \
-DgRPC_BUILD_TESTS=OFF \
-DCMAKE_INSTALL_PREFIX=$MY_INSTALL_DIR \
../..
make -j2
sudo make install
popd
mkdir -p third_party/abseil-cpp/cmake/build
pushd third_party/abseil-cpp/cmake/build
cmake -DCMAKE_INSTALL_PREFIX=$MY_INSTALL_DIR \
-DCMAKE_POSITION_INDEPENDENT_CODE=TRUE \
../..
make
sudo make install
popd
HelloWorld test
cd examples/cpp/helloworld
mkdir -p cmake/build
pushd cmake/build
cmake -DCMAKE_PREFIX_PATH=$MY_INSTALL_DIR ../..
make -j2
编译完成之后
./greeter_server
# 另一终端
./greeter_client
Re:
https://grpc.io/docs/languages/cpp/quickstart/
https://blog.csdn.net/weileshenghuo1/article/details/104428017