grpc gitee镜像编译
git clone https://gitee.com/githubplus/grpc.gitcd grpcgit taggit checkout v1.20.0修改.gitmodules文件,替换其中的github源为gitee源[submodule "third_party/zlib"]path = third_party/zliburl = https://gitee.c...
·
因为github被墙的厉害,git clone很慢,grpc submodule还特别多,幸亏找到了gitee上的源,感谢gitee/githubplus作者
下载编译步骤如下:
编译grpc需要go支持,windows编译需要nasm,在ubuntu上可使用apt直接安装
sudo apt install golang yasm nasm
git clone https://gitee.com/githubplus/grpc.git
cd grpc
git tag
git checkout v1.20.0
修改.gitmodules
文件,替换其中的github源为gitee源
[submodule "third_party/zlib"]
path = third_party/zlib
url = https://gitee.com/githubplus/zlib
# 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/githubplus/protobuf.git
branch = 3.0.x
[submodule "third_party/gflags"]
path = third_party/gflags
url = https://gitee.com/githubplus/gflags.git
[submodule "third_party/googletest"]
path = third_party/googletest
url = https://gitee.com/githubplus/googletest.git
[submodule "third_party/boringssl"]
path = third_party/boringssl
url = https://gitee.com/githubplus/boringssl.git
[submodule "third_party/benchmark"]
path = third_party/benchmark
url = https://gitee.com/githubplus/benchmark.git
[submodule "third_party/boringssl-with-bazel"]
path = third_party/boringssl-with-bazel
url = https://gitee.com/githubplus/boringssl.git
[submodule "third_party/cares/cares"]
path = third_party/cares/cares
url = https://gitee.com/githubplus/c-ares.git
branch = cares-1_12_0
[submodule "third_party/bloaty"]
path = third_party/bloaty
url = https://gitee.com/githubplus/bloaty.git
[submodule "third_party/abseil-cpp"]
path = third_party/abseil-cpp
url = https://gitee.com/githubplus/abseil-cpp
[submodule "third_party/libcxxabi"]
path = third_party/libcxxabi
url = https://gitee.com/githubplus/libcxxabi.git
branch = release_60
[submodule "third_party/libcxx"]
path = third_party/libcxx
url = https://gitee.com/githubplus/libcxx.git
branch = release_60
[submodule "third_party/data-plane-api"]
path = third_party/data-plane-api
url = https://gitee.com/githubplus/data-plane-api.git
[submodule "third_party/googleapis"]
path = third_party/googleapis
url = https://gitee.com/githubplus/googleapis.git
[submodule "third_party/protoc-gen-validate"]
path = third_party/protoc-gen-validate
url = https://gitee.com/githubplus/protoc-gen-validate.git
[submodule "third_party/upb"]
path = third_party/upb
url = https://gitee.com/githubplus/upb.git
git submodule update --init
cd third_party/protobuf
类似修改protobuf
的.gitmodules
后,执行git submodule update --init
[submodule "third_party/benchmark"]
path = third_party/benchmark
url = https://gitee.com/githubplus/benchmark.git
[submodule "third_party/googletest"]
path = third_party/googletest
url = https://gitee.com/githubplus/googletest.git
ignore = dirty
使用cmake
构建
mkdir build/linux-x86_64
cd build/linux-x864_64
cmake ../..
make
使用mingw
交叉编译
mkdir -p build/mingw32
cd build/mingw32
cmake ../.. -DCMAKE_C_COMPILER=i686-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=i686-w64-mingw32-g++ -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_PROCESSOR=x86
make grpc++
mkdir -p build/mingw64
cd build/mingw64
cmake ../.. -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_PROCESSOR=x86_64
make grpc++
error
Please compile grpc with _WIN32_WINNT of at least 0x600 (aka Windows Vista)
在include/grpc/impl/codegen/port_platform.h
中添加
#if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x0600
#endif
#ifndef _WIN32_WINNT
#error \
"Please compile grpc with _WIN32_WINNT of at least 0x600 (aka Windows Vista)"
#else /* !defined(_WIN32_WINNT) */
#if (_WIN32_WINNT < 0x0600)
#error \
"Please compile grpc with _WIN32_WINNT of at least 0x600 (aka Windows Vista)"
#endif /* _WIN32_WINNT < 0x0600 */
#endif /* defined(_WIN32_WINNT) */
find . -name *.a
静态库
./libgrpc.a
./libgrpc++.a
./libaddress_sorting.a
./libgpr.a
./third_party/protobuf/libprotobuf.a
./third_party/boringssl/ssl/libssl.a
./third_party/boringssl/crypto/libcrypto.a
./third_party/cares/cares/lib/libcares.a
./third_party/zlib/libzlibstatic.a
Makefile中链接
GRPC_LIBS += protobuf grpc++ grpc gpr address_sorting cares ssl crypto z
LDFLAGS += $(addprefix -l, $(GRPC_LIBS))
ubuntu16.04
下编译好的库https://gitee.com/ithewei/grpc-release.git
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
已为社区贡献6条内容
所有评论(0)