Centos7.6搭建grpc開發環境

1 安裝依賴

yum install -y glib-headers gcc-c++?gcc?autoconf libtool?pkg-config?automake make unzip

yum install?libgflags-dev libgtest-dev?clang libc++-dev

yum groupinstall -y "Development Tools"

2 下載grpc源碼

git clone https://github.com/grpc/grpc.git

cd grpc

git submodule update --init //更新第三方源碼

3 安裝protobuf

cd third_party/protobuf/

git submodule update --init --recursive? ? //確保克隆子模塊,更新第三方源碼

./autogen.sh? ? //生成配置腳本

./configure? ? //生成Makefile文件,為下一步的編譯做準備,可以加上安裝路徑:--prefix=path

make ?&& make install &&ldconfig

相關命令簡介:

????make uninstall?:?卸載命令

????make clean : 清除編譯產生的可執行文件及目標文件 (object file,*.o)。

????make distclean : 除了清除可執行文件和目標文件外,把 configure 所產生的 Makefile 也清除掉。

? ? ldconfig : 更新共享庫緩存

? ? ldconfig -p|grep proto : 查看protobuf庫相關的庫

????which protoc : 查看軟件的安裝位置

????protoc --version : 檢查是否安裝成功

4 安裝gprs

? ? cd ../..

? ? make && make install?&& ldconfig

5 配置環境變量

vim?~/.bash_profile

????PATH=$PATH:$HOME/bin:/root/grpc/bins/opt

????export PATH

????export LD_LIBRARY_PATH=/usr/local/lib/:/root/grpc/libs/opt

????export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig

source?~/.bash_profile

ldconfig

6 ?grpc測試

cd /root/grpc/examples/cpp/helloworld

make

./greeter_server

./greeter_client

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容