Resolving Protobuf Configuration Issue Without Sudo Access

Resolving Protobuf Configuration Issue Without Sudo Access

When compiling projects that depend on the Protocol Buffers (protobuf) library, you may encounter configuration errors if the library is not found. In environments where you don't have sudo privileges, the solution requires a bit more effort.

Problem Description

During the CMake build configuration process, you might encounter an error like:

复制代码
Could NOT find Protobuf (missing: Protobuf_LIBRARIES Protobuf_INCLUDE_DIR)

This suggests that CMake is unable to locate the protobuf libraries and include directories.

Solution

1. Download Protobuf Source

First, obtain the Protobuf source code from the official repository:

bash 复制代码
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protobuf-all-3.17.3.tar.gz

Note: Adjust the version number and URL based on the version you need.

2. Extract and Build Protobuf

Extract the downloaded source and build it:

bash 复制代码
tar xvf protobuf-all-3.17.3.tar.gz
cd protobuf-3.17.3
./configure --prefix=$HOME/local
make
make install

This compiles and installs protobuf in a local directory within your home directory.

3. Adjust Environment Variables

Update your environment variables to ensure tools and libraries can find your local protobuf installation:

bash 复制代码
export PATH=$HOME/local/bin:$PATH
export LD_LIBRARY_PATH=$HOME/local/lib:$LD_LIBRARY_PATH
export PKG_CONFIG_PATH=$HOME/local/lib/pkgconfig:$PKG_CONFIG_PATH

To make these changes permanent, add the above lines to your .bashrc or .bash_profile.

4. Re-run CMake

Navigate back to your project's build directory and run CMake:

bash 复制代码
cd /path/to/your/build/directory
cmake ..

If CMake is still unable to find Protobuf, you can specify the paths manually:

bash 复制代码
cmake -DProtobuf_INCLUDE_DIR=$HOME/local/include -DProtobuf_LIBRARIES=$HOME/local/lib ..
相关推荐
FreeBuf_3 天前
公开GitHub Issue可诱骗AI泄露私有数据,绕过防护仅需一词
人工智能·github·issue
csdn_aspnet3 天前
开源项目在GitHub上的破圈方法论,解析Star增长、Issue响应、Contributor引导等真实运营技巧
开源·github·issue·readme·star
想你依然心痛8 天前
AtomCode在开源项目维护中的实战:自动处理Issue和PR Review
开源·issue
江畔柳前堤1 个月前
github实战指南02-仓库管理与 Issue
人工智能·深度学习·github·信号处理·caffe·wps·issue
江畔柳前堤1 个月前
github实战指南07-CLI 与高级技巧
前端·人工智能·chrome·深度学习·github·caffe·issue
放风铃的兔子1 个月前
我把 5 个 Python bug 投进 CubeSandbox 当沙盘 —— 从 envd 协议反编译到一键 RED→GREEN
bug·issue
●VON1 个月前
AtomGit Flutter鸿蒙客户端:Issue管理
flutter·华为·架构·harmonyos·鸿蒙·issue
海岸线科技1 个月前
飞书 Issue/8D Agent:从“被动救火”到“主动免疫”的实测报告
汽车·飞书·制造·issue
程序员的程2 个月前
从一个 issue 到阮一峰周刊推荐:stock-sdk 的开源成长记
开源·issue
Loli_Wolf2 个月前
AI 编码 Agent 的工程实践:Issue 到 PR 的自动化不是魔法
人工智能·自动化·issue