赞
踩
## 下载 cd /usr/local/lib wget https://github.com/protocolbuffers/protobuf/releases/download/v3.15.6/protobuf-cpp-3.15.6.tar.gz #2.下载下来后解压压缩包,并进入目录 tar -xzvf protobuf-cpp-3.15.6.tar.gz cd protobuf-3.15.6 #3.设置编译目录 ./configure --prefix=/usr/local/protobuf #4.安装检测(时间较长) make check #5.安装及编译 sudo make && sudo make install #6.配置环境变量 vim ~/.bash_profile #在文件结尾添加环境变量 export PROTOBUF=/usr/local/protobuf export PATH=$PATH:$PROTOBUF/bin #使用source命令,使配置文件生效 source ~/.bash_profile #7.测试按照结果 protoc --version
make check的结果如下:
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.13.0/protobuf-all-3.13.0.tar.gz tar -zxvf protobuf-all-3.13.0.tar.gz cd protobuf-3.13.0/ ./configure --prefix=/usr/local/protobuf make make install vi /etc/profile #文件底部增加 #protobuf config #(动态库搜索路径) 程序加载运行期间查找动态链接库时指定除了系统默认路径之外的其他路径 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/protobuf/lib/ #(静态库搜索路径) 程序编译期间查找动态链接库时指定查找共享库的路径 export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/protobuf/lib/ #执行程序搜索路径 export PATH=$PATH:/usr/local/protobuf/bin/ #c程序头文件搜索路径 export C_INCLUDE_PATH=$C_INCLUDE_PATH:/usr/local/protobuf/include/ #c++程序头文件搜索路径 export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/usr/local/protobuf/include/ #pkg-config 路径 export PKG_CONFIG_PATH=/usr/local/protobuf/lib/pkgconfig/ source /etc/profile protoc --version
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。