grpc-c编译

  • IPC, Server
  • 857 clicked

  关于grpc-c的示例代码地址 https://github.com/lixiangyun/grpc-c.git ,该项目采用gRPC v1.17.2 .

故障排查罗列

本文采用CentOS系统,其中grpc-c趟坑过程记录如下

  1. 安装依赖项

  1. 找不到库openssl 或zlib

No package 'zlib' found
Package openssl was not found in the pkg-config search path.
Perhaps you should add the directory containing openssl.pc' to the PKG_CONFIG_PATH environment variable No package 'openssl' found Package openssl was not found in the pkg-config search path. Perhaps you should add the directory containingopenssl.pc'
to the PKG_CONFIG_PATH environment variable
No package 'openssl' found
Package openssl was not found in the pkg-config search path.
Perhaps you should add the directory containing openssl.pc' to the PKG_CONFIG_PATH environment variable No package 'openssl' found Package zlib was not found in the pkg-config search path. Perhaps you should add the directory containingzlib.pc'
to the PKG_CONFIG_PATH environment variable
No package 'zlib' foun

  1. 找不到XXX.so

  1. 重新编译如果无法找到文件

//zconf.h missing when building with make
make clean

  1. 编译测试文件时链接错误

//usr/local/lib/libgrpc-c.so:对‘grpc_call_unref’未定义的引用
collect2: 错误:ld 返回 1
make[2]: [foo/foo_bin] 错误 1
make[1]:
[foo/CMakeFiles/foo_bin.dir/all] 错误 2
make: [all] 错误 2
[ 16%] Linking C executable foo_bin
//usr/local/lib/libgrpc-c.so:对‘grpc_call_unref’未定义的引用
collect2: 错误:ld 返回 1
make[2]:
[foo/foo_bin] 错误 1
make[1]: [foo/CMakeFiles/foo_bin.dir/all] 错误 2
make:
[all] 错误 2

  搜索该文件,grpc已经在另一个位置安装有,即/usr/lib以及/usr/local/lib都有该动态链接库,以及相应的.h文件在以上两个目录的include目录中,删除重复的。重新编译,即可解决问题。

Build

If you want to install dependencies in a different directory other than /usr/local/, use ./builddeps.sh and ./buildlib.sh

Examples

To run example code:

Package

赞赏

微信赞赏支付宝赞赏

发表评论

邮箱地址不会被公开。 必填项已用*标注