現在ubuntu 19.04系統中安裝golang
1. 下載 源碼包
https://golang.google.cn/doc/install?download=go1.13.8.linux-amd64.tar.gz
2. 解壓並執行下列操作
tar -C /usr/local -xzf go1.2rc3.linux-amd64.tar.gz
// 添加 golang path cd /home mkdir gopath
3.添加環境變量
vim /etc/profile
//在文件末尾添加這幾行 如果有改動對應改一下
export GOROOT=/usr/local/go
export GOARCH=amd64
export GOOS=linux
export GOPATH=/home/gopath
export GOBIN=$GOROOT/bin
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
export GOPROXY=https://goproxy.cn
export GO111MODULE=auto
4.最后source 更改的文件
source /etc/profile
5.測試一下環境變量添加的是否成功
go env
有添加的環境變量輸出的就說明成功了
二.安裝protobuf
1. 源碼包下載 (可以git clone 下載 也可以 瀏覽器下載 解壓 進到文件夾內 )
https://github.com/protocolbuffers/protobuf
2.安裝 依賴
sudo apt-get install autoconf automake libtool curl make g++ unzip
3. 安裝 protobuf
$ cd protobuf $ ./autogen.sh $ ./configure $ make $ sudo make install $ sudo ldconfig
$ protoc --version
有版本輸出就可以了
三. 安裝 grpc
1.下載 grpc 源碼包 (也可以 用瀏覽器下載 下載之后 解壓一樣的)
git clone https://github.com/grpc/grpc.git
2.安裝依賴
sudo apt-get install pkg-config sudo apt-get install autoconf automake libtool make g++ unzip sudo apt-get install libgflags-dev libgtest-dev sudo apt-get install clang libc++-dev sudo apt-get install openssl sudo apt-get install libssl-dev
sudo apt-get install zlib1g-dev
還有一些 源碼安裝的依賴
安裝依賴 c-ares 網址(我使用的最新的) https://c-ares.haxx.se/download/
安裝步驟如下:
./configure make make install 安裝 abseil依賴 下載鏈接 https://github.com/abseil/abseil-cpp
安裝步驟如下:
mkdir build && cd build
cmake ..
make
sudo make install
3.安裝grpc
將編譯好的 源碼包 abseil-cpp/ 中的所有考到 (自己的grpc目錄)/grpc/third_party/abseil-cpp 中
然后進行 grpc 源碼安裝
make //從Makefile讀取指令,然后編譯
sudo make install
4.測試grpc 安裝成功了
進入
grpc/examples/cpp/helloworld
編譯
make
開兩個終端分別在helloworld 中執行
./greeter_server
./greeter_client

成功!!
依賴包我已經放在 百度雲里了 要是git下載慢可以自行百度雲下載
鏈接:https://pan.baidu.com/s/19pWCdR5Ga0LXbhwPrqvBvQ 提取碼:du2s
