protobuf 编译安装
今天在安装protobuf时,发现网上的protobuf编译安装教程已经落后了,所以记录下来,有需要的朋友可参考。
我是在Ubuntu虚拟机上安装的。
首先在githup上下载源码:
wget -v -O protobuf.zip https://codeload.github.com/protocolbuffers/protobuf/zip/master
然后解压
unzip protobuf.zip
网上的文章是进入该目录后执行:
./configure --prefix=/usr/local/protobuf
但此时,你会发现目录下缺少configure文件,不过有个autogen.sh的脚本,里面有几行注释:
[code]# Run this script to generate the configure script and other files that will # be included in the distribution. These files are not checked in because they # are automatically generated.
即运行这个脚本以生成configure脚本及其他文件。所以我就运行这个脚本,但却报错了:
[code]+ mkdir -p third_party/googletest/m4 + autoreconf -f -i -Wall,no-obsolete ./autogen.sh: 37: ./autogen.sh: autoreconf: not found
此时需要安装其他辅助工具:
sudo apt-get install automake autoconf
到这里以为ok了,继续运行脚本autogen.sh,发现还是报错了:
[code]+ mkdir -p third_party/googletest/m4 + autoreconf -f -i -Wall,no-obsolete configure.ac:104: error: possibly undefined macro: AC_PROG_LIBTOOL If this token and others are legitimate, please use m4_pattern_allow. See the Autoconf documentation. autoreconf: /usr/bin/autoconf failed with exit status: 1
原来还缺少一个依赖:
sudo apt-get install libtool
完了后运行脚本autogen.sh没问题了,现在开始执行
./configure --prefix=/usr/local/protobuf
也ok了,后开始编译
make
make check
安装:
sudo make install
配置环境变量:
vim /etc/profile
增加如下2行:
[code]export PATH=$PATH:/usr/local/protobuf/bin/ export PKG_CONFIG_PATH=/usr/local/protobuf/lib/pkgconfig/
因为我使用protobuf来生成go语言的代码,因此,还需安装go语言的生成工具:
go get -u github.com/golang/protobuf/protoc-gen-go
完了后把生成的protoc-gen-go文件拷贝到$GOROOT下。
protobuf编译安装完毕。
阅读更多- Mac安装Protobuf编译Java
- Google Protobuf的安装、配置、以及简单demo编译
- 如何编译安装protobuf极其python版本
- google protobuf编译安装(ImportError: No module named google.protobuf.internal)
- Android 中protobuf 的安装,编译和使用
- centos6.5 64位 protobuf和protobuf-c源文件编译&安装
- mac 安装protobuf,并编译为java,c++,python
- 【protobuf 002】 protobuf+vs2013编译安装
- Google_Protobuf协议——Protobuf安装编译
- protobuf的编译与安装(教程)附带资源(亲测,Mac下可以用)
- CentOS6.5下python版本的protobuf编译及安装
- win编译安装 protobuf3.2
- 平台移植的各种情况 --- 关于 protobuf的编译、安装,以及开发
- Mac下protobuf安装,并用maven编译导出jar包
- LINUX下编译安装PROTOBUF 【UBUNTU10.04+PROTOBUF-2.4.1.TAR.GZ】
- google protobuf编译安装(ImportError: No module named google.protobuf.internal)
- linux下protobuf 下载并cmake编译安装全过程脚本
- protobuf+vs2013编译安装
- Google Protobuf的安装、配置、以及简单demo编译
- protobuf安装配置和编译成java文件教程(for mac)