# grpc_serv **Repository Path**: misc_projects/grpc_serv ## Basic Information - **Project Name**: grpc_serv - **Description**: 测试仓库:建立 gRPC 服务端。客户端如果是web的话,需要通过诸如 ngigx 代理进行协议转换。 - **Primary Language**: C++ - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-08-28 - **Last Updated**: 2024-10-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # README ## 1. 如何编译protobuf,并链接到APP 编译protobuf: ```bash git clone https://github.com/protocolbuffers/protobuf.git cmake -Dprotobuf_BUILD_TESTS=OFF -DABSL_BUILD_TESTING=OFF -DABSL_USE_GOOGLETEST_HEAD=OFF -DABSL_PROPAGATE_CXX_STD=ON -DCMAKE_CXX_STANDARD=17 .. ``` 链接到APP(CMake): ```cmake # protobuf # find_package(Protobuf 3.15.0 REQUIRED) find_package(protobuf REQUIRED CONFIG) find_package( absl REQUIRED ) ``` ```cmake target_link_libraries(grpcxx PRIVATE libnghttp2::nghttp2 PUBLIC libuv::uv absl::log_internal_message absl::log_internal_check_op ) ``` ## 2. 编译 gRPC ```bash git clone https://github.com/grpc/grpc.git mkdir grpc/cmake/build && cd grpc/cmake/build cmake -DCMAKE_BUILD_TYPE=Release -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DgRPC_SSL_PROVIDER=package ../.. ``` ## references - [gRPC official C++ Quick start]( https://grpc.io/docs/languages/cpp/quickstart/) - [gRPC CMake example](https://github.com/faaxm/exmpl-cmake-grpc/blob/master/proto/CMakeLists.txt) ### other references - [blog: gRPC Tutorial](https://leimao.github.io/blog/gRPC-Tutorial/) - [gRPC C++ demo](https://github.com/chungphb/grpc-cpp) - [使用c++如何实现在gRPC中传输文件](https://www.cnblogs.com/xingmuxin/p/10738488.html) - [利用 gRPC 实现文件的上传与下载](https://blog.yuanpei.me/posts/use-grpc-to-realize-file-upload-and-download/) - [前端从懵逼到入门 gRPC 框架](https://www.cnblogs.com/zhangchaojie/p/15172929.html) - [gRPC-Gateway 快速实战](https://learnku.com/articles/83386) - [gRPC 客户端和服务端一次交互的全流程(九)](https://learnku.com/articles/36225) ## 3. grpc_serv 启动 `grpc_serv`使用多线程支持多客户端下载或上传文件,默认使用CPU个数的一半线程数。或者定义环境变量`GRPC_SERVER_THREAD_NUM`来设置线程数。