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 ..
相关推荐
这家伙是个好家伙7 天前
GitHub Copilot Issue in Visual Studio Code “Status Ready (disabled)“
vscode·github·copilot·issue
fareast_mzh15 天前
Linux scp hidden file issue
linux·运维·issue
wish3661 个月前
.NET App accesses MSSQL to report TLS issue on Linux and Docker
linux·经验分享·docker·sqlserver·.net·devops·issue
ryfdizuo2 个月前
STL Map的使用和性能issue
java·c++·issue
Yan-英杰2 个月前
【BUG】已解决:ModuleNotFoundError: No module named ‘paddle‘
python·bug·excel·pip·paddle·issue
Yan-英杰2 个月前
【BUG】已解决:xlrd.biffh.XLRDError: Excel xlsx file; not supported
开发语言·python·bug·excel·pip·issue
Yan-英杰2 个月前
【BUG】已解决:SyntaxError invalid syntax
人工智能·bug·ai编程·pip·issue
Yan-英杰2 个月前
【BUG】已解决:note: This is an issue with the package mentioned above,not pip.
java·开发语言·python·opencv·bug·pip·issue
com未来5 个月前
VBA 实现outlook 当邮件设置category: red 即触发自动创建jira issue
powerpoint·outlook·issue
小桥流水---人工智能6 个月前
Elsevier(爱思唯尔)如何查询特刊special issue
issue