protobuf安装后出现libprotobuf.so.6 not found after installation

本文详细介绍了如何通过configure命令将包安装到/usr目录下,避免了LD_LIBRARY_PATH路径的问题。提供了实例和注意事项。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Please follow the instructions in README.txt:

** Hint on install location **

By default, the package will be installed to /usr/local. However,
on many platforms, /usr/local/lib is not part of LD_LIBRARY_PATH.
You can add it, but it may be easier to just install to /usr
instead. To do this, invoke configure as follows:

./configure --prefix=/usr

If you already built the package with a different prefix, make sure
to run "make clean" before building again.

** 翻译 translate **

默认情况下,包会被安装在/usr/local路径下。但是,在某些系统平台上(如Ubuntu 11),/usr/local/lib路径并不包含在LD_LIBRARY_PATH中。你可以手动添加,但也可以很方便的通过安装到/usr路径下,调用configure命令参数如下

./configure --prefix=/usr

如果你的包已经编译过,确保先运行"make clean"再重新编译。

reference:[url]http://code.google.com/p/protobuf/issues/detail?id=213[/url]
ubuntu@ubuntu:~$ pip install protobuf==3.20.3 Defaulting to user installation because normal site-packages is not writeable WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, '[SSL: UNEXPECTED_EOF_WHILE_READING] EOF occurred in violation of protocol (_ssl.c:1007)'))': /simple/protobuf/ WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, '[SSL: UNEXPECTED_EOF_WHILE_READING] EOF occurred in violation of protocol (_ssl.c:1007)'))': /simple/protobuf/ WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, '[SSL: UNEXPECTED_EOF_WHILE_READING] EOF occurred in violation of protocol (_ssl.c:1007)'))': /simple/protobuf/ WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, '[SSL: UNEXPECTED_EOF_WHILE_READING] EOF occurred in violation of protocol (_ssl.c:1007)'))': /simple/protobuf/ WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, '[SSL: UNEXPECTED_EOF_WHILE_READING] EOF occurred in violation of protocol (_ssl.c:1007)'))': /simple/protobuf/ Could not fetch URL https://pypi.org/simple/protobuf/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/protobuf/ (Caused by SSLError(SSLEOFError(8, '[SSL: UNEXPECTED_EOF_WHILE_READING] EOF occurred in violation of protocol (_ssl.c:1007)'))) - skipping ERROR: Could not find a version that satisfies the requirement protobuf==3.20.3 (from versions: none) ERROR: No matching distribution found for protobuf==3.20.3
03-14
### 关于 `libprotobuf.so.23` 的安装路径与依赖问题 在 Ubuntu 系统中,`libprotobuf.so.23` 是 Protocol Buffers 库的一个共享库文件版本。Protocol Buffers 是一种用于序列化结构化数据的语言无关、平台无关的方法。以下是关于该库的相关信息及其可能的解决方案。 #### 1. 默认安装路径 通常情况下,在 Ubuntu 上安装 `libprotobuf-dev` 或者编译后的 Protobuf 库会将动态链接库放置到以下默认路径之一: - `/usr/lib/x86_64-linux-gnu/` - `/usr/local/lib/` 可以通过命令验证是否存在目标文件: ```bash ls /usr/lib/x86_64-linux-gnu/libprotobuf.so* ls /usr/local/lib/libprotobuf.so* ``` 如果未找到特定版本(如 `.so.23`),则可能是当前系统中的 Protobuf 版本不匹配或者尚未正确安装[^1]。 --- #### 2. 安装指定版本的 Protobuf 为了确保安装的是所需的具体版本(例如 `v3.x` 对应的 `.so.23` 文件),可以按照以下步骤操作: ##### 方法一:通过 APT 包管理器安装 尝试更新并安装官方仓库中的最新版 Protobuf 开发包: ```bash sudo apt update sudo apt install libprotobuf23 protobuf-compiler ``` 这一步骤适用于已经支持对应版本的 Ubuntu 发行版。如果没有可用的预构建二进制包,则需考虑手动编译。 ##### 方法二:从源码编译安装 下载指定版本的 Protobuf 源代码,并自行编译生成所需的 `.so` 文件: 1. 下载源码压缩包(假设需要 v3.20.0): ```bash wget https://github.com/protocolbuffers/protobuf/releases/download/v3.20.0/protobuf-cpp-3.20.0.tar.gz tar -xzvf protobuf-cpp-3.20.0.tar.gz cd protobuf-3.20.0/ ``` 2. 配置和编译项目: ```bash ./configure --prefix=/usr make -j$(nproc) sudo make install ``` 3. 更新动态链接器缓存: ```bash sudo ldconfig ``` 完成以上步骤后,应该可以在标准路径下发现新生成的 `libprotobuf.so.23` 文件[^2]。 --- #### 3. 动态链接错误排查 当程序运行时报错提示缺少 `libprotobuf.so.23` 或其他类似的动态库时,可采取如下措施解决问题: - **确认 LD_LIBRARY_PATH 设置** 如果自定义安装位置不在系统的默认搜索范围内,可通过设置环境变量临时解决加载失败的问题: ```bash export LD_LIBRARY_PATH=/path/to/custom/libs:$LD_LIBRARY_PATH ``` 替换 `/path/to/custom/libs` 为实际存放 `.so` 文件的位置。 - **修改全局配置文件** 将新增加的库目录加入到 `/etc/ld.so.conf.d/` 子目录下的某个配置文件里,比如创建名为 `protobuf.conf` 的条目: ```bash echo "/usr/local/lib" | sudo tee /etc/ld.so.conf.d/protobuf.conf sudo ldconfig ``` 这样可以让后续启动的应用自动识别新的共享对象而无需额外干预[^3]。 --- #### 4. 常见兼容性注意事项 某些应用程序可能会严格绑定至某一具体次级编号的小版本号(即 MAJOR.MINOR.PATCH 形式的最后部分)。即使主版本一致也可能因细微差异引发冲突。此时要么升级整个软件栈以适配更高层次需求;要么寻找回退选项还原旧有状态直至满足最低限度要求为止[^4]。 --- ### 示例脚本 以下是一个简单的 Bash 脚本来检测是否已存在有效的 `libprotobuf.so.23` 并给出相应建议处理方式: ```bash #!/bin/bash PROTOBUF_SO="/usr/lib/x86_64-linux-gnu/libprotobuf.so.23" if [[ ! -f "$PROTOBUF_SO" ]]; then echo "Error: Missing $PROTOBUF_SO" read -p "Do you want to attempt installation? (y/n): " choice case "$choice" in y|Y ) sudo apt update && sudo apt install -y libprotobuf23 protobuf-compiler || \ { echo "APT failed, try manual build."; exit 1; } ;; * ) echo "Aborted." exit 0; ;; esac else echo "Found valid library at '$PROTOBUF_SO'. No action required." fi ``` ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值