踩坑一下午,终于在ubantu上部署成功了grpc, 闭坑总结一波
- 安装依赖库
sudo apt-get install pkg-config
sudo apt-get install build-essential autoconf libtool pkg-config
sudo apt-get install libgflags-dev libgtest-dev
sudo apt-get install clang libc++-dev
sudo apt-get install cmake #编译使用,ubantu默认应该是没装的,如果你的机器装了,这步不用执行
- 下载grpc
git clone https://github.com/grpc/grpc.git #网络问题,可能会失败,多试几次
vi grpc/.gitmodules #注意更改实际目录
#删除文件里原有的内容,替换.gitmodules文件里的内容如下
[submodule "third_party/zlib"]
path = third_party/zlib
url = https://gitee.com/Xprice/zlib.git
# When using CMake to build, the zlib submodule ends up with a
# generated file that makes Git consider the submodule dirty. This
# state can be ignored for day-to-day development on gRPC.
ignore = dirty
[submodule "third_party/protobuf"]
path = third_party/protobuf
url = https://gitee.com/Xprice/protobuf.git
[submodule "third_party/googletest"]
path = third_party/googletest
url = https://gitee.com/Xprice/googletest.git
[submodule "third_party/benchmark"]
path = third_party/benchmark
url = https://gitee.com/Xprice/benchmark.git
[submodule "third_party/boringssl-with-bazel"]
path = third_party/boringssl-with-bazel
url = https://gitee.com/Xprice/boringssl.git
[submodule "third_party/re2"]
path = third_party/re2
url = https://gitee.com/Xprice/re2.git
[submodule "third_party/cares/cares"]
path = third_party/cares/cares
url = https://gitee.com/Xprice/c-ares.git
branch = cares-1_12_0
[submodule "third_party/bloaty"]
path = third_party/bloaty
url = https://gitee.com/Xprice/bloaty.git
[submodule "third_party/abseil-cpp"]
path = third_party/abseil-cpp
url = https://gitee.com/Xprice/abseil-cpp.git
branch = lts_2020_02_25
[submodule "third_party/envoy-api"]
path = third_party/envoy-api
url = https://gitee.com/Xprice/data-plane-api.git
[submodule "third_party/googleapis"]
path = third_party/googleapis
url = https://gitee.com/Xprice/googleapis.git
[submodule "third_party/protoc-gen-validate"]
path = third_party/protoc-gen-validate
url = https://gitee.com/Xprice/protoc-gen-validate.git
[submodule "third_party/udpa"]
path = third_party/udpa
url = https://gitee.com/Xprice/udpa.git
[submodule "third_party/libuv"]
path = third_party/libuv
url = https://gitee.com/Xprice/libuv.git
[submodule "third_party/opencensus-proto"]
path = third_party/opencensus-proto
url = https://gitee.com/Xprice/opencensus-proto.git
#更新源
git submodule update --init
#按如下操作,可以解决:Installing via 'make' is no longer supported. Use cmake or bazel instead.
mkdir -p cmake/build
cd cmake/build
cmake ../..
make
sudo make install
- 编译安装protobuf
cd grpc/third_party/protobuf/ #进入protobuf文件夹下
git submodule update --init --recursive
sudo ./autogen.sh #生成configure文件
sudo ./configure
sudo make
sudo make install
sudo ldconfig
#验证是否安装成功
protoc --version
- 编译安装abseil
cd grpc/third_party/abseil-cpp/ #进入abseil文件夹
mkdir build
cd build
cmake ..
make
sudo make install
参考:
https://blog.csdn.net/qq_44519484/article/details/117263951