ubuntu安装指定版本protobuf,无configure,makefile文件报错
- 1.查看protobuf版本
- 2.安装指定版本protobuf
- 3.报错无configure和makefile文件等等,比如安装protobuf3.0版本
- 4.检查protobuf版本
1.查看protobuf版本
1 | # protoc --version |
2.安装指定版本protobuf
前提: 确保一下几个库都有安装
1 | # sudo apt-get install autoconf automake libtool curl make g++ unzip |
在此以安装protobuf3.6版本为例
1 2 3 4 5 6 | # git clone -b v3.6.0 https://github.com/protocolbuffers/protobuf.git //安装哪个版本,v后面直接修改即可 # cd protobuf # git submodule update --init --recursive // 该命令表示克隆protobuf的子模块,主要是gtest //没有反应,没问题继续进行 |
编译protobuf源码,并进行安装
1 2 3 4 5 6 7 8 9 10 11 | // 进入到克隆的protobuf目录 # cd protobuf # ./autogen.sh # ./configure make // 如果没有克隆子模块,make check会失败但是可以继续make install,但是使用某些功能时可能会出错 # make check # sudo make install # sudo ldconfig // 输出protobuf版本信息则表示安装成功 # protoc --version |
3.报错无configure和makefile文件等等,比如安装protobuf3.0版本
生成configure和makefile文件
1 2 3 4 5 6 7 8 | # cd protobuf # aclocal # autoconf # autoheader # automake --add-missing # ./configure # make # sudo make install |
若有报错出现configure.ac:*: error: required file ‘autoconf/ltmain.sh’ not found
安装libtools
1 | # sudo apt install libtool |
执行
1 | # libtoolize --automake --copy --debug --force |
若有报错出现config.status: error: cannot find input file: `Makefile.in’
1 2 3 4 5 6 | # aclocal # libtoolize –automake # automake --add-missing # ./configure # make # sudo make install |
4.检查protobuf版本
1 | # protoc --version |
参考链接
参考链接:自动生成configure和makefile
参考链接:Ubuntu18.04同时安装两个版本的protobuf