Ubuntu 18.04 上源码安装 protobuf 3.7.0


🔧 1️⃣ 安装依赖

复制代码
sudo apt update
sudo apt install -y autoconf automake libtool curl make g++ unzip

📥 2️⃣ 下载源码

复制代码
cd ~
git clone https://github.com/protocolbuffers/protobuf.git
cd protobuf
git checkout v3.7.0

⚙️ 3️⃣ 编译 & 安装

复制代码
# 生成配置脚本
./autogen.sh

# 配置编译参数(默认安装到 /usr/local)
./configure

# 编译
make -j4

# 安装
sudo make install

# 更新动态链接库
sudo ldconfig

🧪 4️⃣ 验证安装

查看版本:

复制代码
protoc --version

应该会显示:

复制代码
libprotoc 3.7.0

⚠️ 可能的补充

安装到指定位置

如果你想自定义安装路径:

复制代码
./configure --prefix=/opt/protobuf-3.7.0
make -j4
sudo make install

然后:

复制代码
export PATH=/opt/protobuf-3.7.0/bin:$PATH
sudo ldconfig

同时支持 Python

如果你需要 Python 绑定:

复制代码
cd python
python3 setup.py build
python3 setup.py test
sudo python3 setup.py install

🔥 小结

1️⃣ 下载并 checkout 到 v3.7.0

2️⃣ ./autogen.sh && ./configure && make -j4 && sudo make install

3️⃣ sudo ldconfig 更新动态库

相关推荐
小猿姐1 小时前
唯品会大规模数据库云原生实践:基于 KubeBlocks 管理数千实例的统一运维之路
运维·elasticsearch·云原生
七歌杜金房6 小时前
我终于又有了自己的 Linux 电脑
linux·debian·mac
SkyWalking中文站14 小时前
认识 Horizon UI · 5/17:3D 基础设施地图
运维·监控·自动化运维
tntxia1 天前
linux curl命令详解_curl详解
linux
扛枪的书生1 天前
Linux 网络管理器用法速查
linux
SkyWalking中文站1 天前
认识 Horizon UI · 1/17:SkyWalking 新一代可观测性控制台
运维·前端·监控
顺风尿一寸2 天前
Java Socket 内核之旅:从 SocketChannel.read() 到 tcp_recvmsg 与 epoll 的完整调用链路
linux
雪梨酱QAQ2 天前
Kubeneters HA Cluster部署
运维
江华森2 天前
Spring Cloud 微服务全栈实战:从 Eureka 到 Docker Compose 一文贯通
运维
江华森2 天前
Matplotlib 数据绘图基础入门
运维