网上很多关于 grpc安装和编译的参考文档,但是都没给出碰到问题的具体解决办法,又或者是软件版本和过程交代的不够详细,这里记录一个可用的配置和测试过程。 首先需要确保cmake的版本要高于3.11 需要下载的是 cmake-3.16.1-Linux-x86_64.sh 安装过程注意选择yes 然后下载grpc, 下载的是 (HEAD detached
CMake将自动下载gRPC及其依赖(如googletest、protobuf等)的源代码。 配置完成后,执行构建命令: cmake --build cmake-build -t greeter_client greeter_server 1. 构建完成后将在cmake-build/helloworld目录下生成客户端和服务器的可执行程序greeter_client和greeter_server。分别在两个终端运行这两个程序即可。 3....
CMake always reports back errors because all paths after installing are prepended with/usr/usrand thus the corresponding cmake files are not found. root@runnerpi:~/grpc/examples/cpp/helloworld/cmake/build# cmake ../.. -- The C compiler identification is GNU 12.2.0 -- The CXX compiler id...
编写CMake文件 在工作目录创建CMakeLists.txt,写入内容如下 cmake_minimum_required(VERSION 3.5) project(test) set(CMAKE_CXX_STANDARD 11) set(PROTO_PATH ${CMAKE_CURRENT_SOURCE_DIR}/test_proto) file(GLOB PROTO_FILES ${PROTO_PATH}/*.cc) find_package(Threads REQUIRED) find_package(Protobuf CONF...
注意一定执行要export,设置好设置 CMAKE_INSTALL_PREFIX,这样有利于example项目的编译 $ export MY_INSTALL_DIR=$HOME/.local # 确保路径已经存在 $ mkdir -p $MY_INSTALL_DIR #将bin目录安装到环境中 $ export PATH="$MY_INSTALL_DIR/bin:$PATH" ...
Example cmake project for grpc / protobuf. Contribute to faaxm/exmpl-cmake-grpc development by creating an account on GitHub.
# # cmake build file for C++ staffbook example. # Assumes protobuf and gRPC have been installed using cmake. # See cmake_externalproject/CMakeLists.txt for all-in-one cmake build # that automatically builds all the dependencies before building staffbook. cmake_minimum_required(VERSION 3.5...
因为之前已经通过shell脚本完成了proto文件的编译,也就是该生成的代码已经生成完了,所以这里的CMakeLists.txt文件就不需要像官方example中的CMakeLists.txt那么复杂了,只需要将生成的代码导入(add_library)然后和grpc的库进行链接就可以了。最后在把服务端和客户端代码生成可执行文件就可以了。
我正在尝试使用 gRPC 库,但是我不断收到错误消息,告诉我找不到 .cmake 文件,或者出现链接器错误,可能是由于我的 CMakeLists.txt 造成的。在我下面的示例中,他们将 cmake 中的库简单地称为 gRPC,并且我也尝试了关键字 grpc_cpp_plugin,但是似乎都不起作用。
# # A more robust approach to add dependency on gRPC is using # cmake's ExternalProject_Add (see cmake_externalproject/CMakeLists.txt). # Include the gRPC's cmake build (normally grpc source code would live # in a git submodule called "third_party/grpc", but this example lives in #...