码迷,mamicode.com
首页 > 其他好文 > 详细

gRPC应用实践

时间:2019-12-23 20:46:42      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:latest   gedit   cache   strong   width   serve   dev   实践   frame   

What is RPC?

Remote Procedure Call is a high-level model for client-server communication. Assume there are two computers, computer A(on local) and computer B(on some network). Computer B provides some API’s, let’s say it has some procedures which can be run and these procedures can be run on computer B itself.

What is gRPC?

gRPC is a high performance, open source universal RPC Framework. In simple words, it enables the server and client applications to communicate transparently and build connected systems. GRPC is developed and open sourced by Google.

 

 

Linux server (C++) Setup

gRPC C++ - Build from source

(1) Pre-requisites

$ sudo apt-get install build-essential autoconf libtool pkg-config
# If you plan to build from source and run tests, install the following as well:
$ sudo apt-get install libgflags-dev libgtest-dev
$ sudo apt-get install clang-5.0 libc++-dev

(2) Clone the repository (including submodules)

$ git clone -b $(curl -L https://grpc.io/release) https://github.com/grpc/grpc
$ cd grpc
$ git submodule update --init

(3) Building with CMake

$ sudo mkdir -p cmake/build

# Check if the cmake version > 3.6, otherwise install the latest version follow below steps:

技术图片  

$ cd cmake/build

$ sudo apt-get install golang

$ sudo cmake ../.. -DBUILD_SHARED_LIBS=ON

$ sudo make

 

# Copy all needed libs, dlls and executables to the specified folder

$ sudo ln -sf ~/min-projects/grpc/cmake/build/* /usr/bin/

$ sudo cp -f /home/mzhu/min-projects/grpc/cmake/build/*.so /usr/local/lib

$ sudo cp -f /home/mzhu/min-projects/grpc/cmake/build/*.a /usr/local/lib

$ sudo cp -f /home/ mzhu /min-projects/grpc/libs/opt/pkgconfig/*.pc /usr/lib/pkgconfig/

# Add the line “/usr/local/lib” into the file “/etc/ld.so.conf”

$ sudo gedit /etc/ld.so.conf

# Refresh shared library cache

$ sudo ldconfig

(4) Install protoc along with the C++ runtime

$ cd ~/min-projects/grpc/third_party/protobuf/

$ ./autogen.sh

$ ./configure

$ sudo make

$ sudo make install

(5) Run an example to verify the environment

 技术图片

gRPC应用实践

标签:latest   gedit   cache   strong   width   serve   dev   实践   frame   

原文地址:https://www.cnblogs.com/carsonzhu/p/12088144.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!