报错解决:libcudart.so和libprotobuf.so链接库未找到

报错解决:libcudart.so和libprotobuf.so链接库未找到

此博客介绍了博主在编译软件包时遇到的两个报错,主要是libcudart和libprotobuf两个动态链接库未找到的问题,分析了其原因,并给出了解决方法。

libcudart.so链接库未找到

libprotobuf.so是Google Protocol Buffers库的动态链接库文件。它用于在计算机系统中使用Protocol Buffers数据进行序列化和反序列化操作。

报错如下:

/usr/bin/ld: warning: libcudart.so.11.0, needed by XXX, not found.

原因

cuda未安装或cuda版本存在问题,抑或版本过低,抑或版本过高,需要安装CUDA >= 11.0 并且CUDA <= 12.0。

解决方法

前往官网,下载对应版本的cuda并安装,例如我选择安装cuda11.1,依次选择Linux-x86_64-Ubuntu-18.04-runfile(local),如下图所示。

注意,我选择deb(local)安装会报以下错误,因此选择runfile(local)进行安装。

bash 复制代码
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 cuda : Depends: cuda-12-1 (>= 12.1.1) but it is not going to be installed
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:1 and /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:3
W: Target Packages (main/binary-i386/Packages) is configured multiple times in /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:1 and /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:3
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:1 and /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:3
W: Target Translations (main/i18n/Translation-en_US) is configured multiple times in /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:1 and /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:3
W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:1 and /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:3
W: Target DEP-11 (main/dep11/Components-amd64.yml) is configured multiple times in /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:1 and /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:3
W: Target DEP-11 (main/dep11/Components-all.yml) is configured multiple times in /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:1 and /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:3
W: Target DEP-11-icons-small (main/dep11/icons-48x48.tar) is configured multiple times in /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:1 and /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:3
W: Target DEP-11-icons (main/dep11/icons-64x64.tar) is configured multiple times in /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:1 and /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:3
W: Target CNF (main/cnf/Commands-amd64) is configured multiple times in /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:1 and /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:3
W: Target CNF (main/cnf/Commands-all) is configured multiple times in /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:1 and /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:3
E: Unable to correct problems, you have held broken packages.

运行如下命令,可以顺利安装:

bash 复制代码
wget https://developer.download.nvidia.com/compute/cuda/11.1.0/local_installers/cuda_11.1.0_455.23.05_linux.run
sudo sh cuda_11.1.0_455.23.05_linux.run

更多详细的安装过程,例如:运行.run文件后如何勾选选项等,可以参照我的另一篇博客CUDA安装

libprotobuf.so链接库未找到

libcudart.so是CUDA运行时库的动态链接库文件。CUDA(Compute Unified Device Architecture)是由NVIDIA开发的用于并行计算的平台和编程模型。该库文件提供了在使用CUDA进行GPU编程时所需的运行时支持。

报错如下:

CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):

Could NOT find Protobuf (missing: Protobuf_INCLUDE_DIR)

Call Stack (most recent call first):

/usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)

/usr/share/cmake-3.16/Modules/FindProtobuf.cmake:624 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)

CMakeLists.txt:31 (find_package)

或者

/usr/bin/ld: warning: libprotobuf.so.17, needed by XXX, not found.

原因

protobuf未安装或系统默认安装的protobuf版本较低,需要按照高版本的protobuf。

解决方法

如果运行指令sudo apt install libprotobuf-dev无法安装对应版本的protobuf,则可以按照如下方法进行安装 :

  1. 前往protobuf的github官网下载对应版本(此处安装的是libprotobuf-dev==3.6.1)。
bash 复制代码
git clone https://github.com/protocolbuffers/protobuf.git
git checkout v3.6.1
  1. 运行如下命令进行安装:
bash 复制代码
./autogen.sh
./configure --prefix=/usr/local/protobuf #为了以后便于管理
make -j4 #多核编译加快速度
sudo make install
  1. 安装完之后,动态库的位置在/usr/local/protobuf/lib/,并创建(或修改)软链接:
bash 复制代码
sudo ln -s /usr/local/protobuf/lib/libprotoc.so.17.0.0 /usr/lib/libprotoc.so
sudo ln -s /usr/local/protobuf/lib/libprotobuf.so.17.0.0 /usr/lib/libprotobuf.so
sudo ln -s /usr/local/protobuf/lib/libprotobuf-lite.so.17.0.0 /usr/lib/libprotobuf-lite.so

这一点要注意:若你的电脑原protobuf库的位置不在/usr/local/protobuf/lib/,需要对应修改一下。

相关推荐
Lary_Rock43 分钟前
RK3576 LINUX RKNN SDK 测试
linux·运维·服务器
云飞云共享云桌面3 小时前
8位机械工程师如何共享一台图形工作站算力?
linux·服务器·网络
Peter_chq3 小时前
【操作系统】基于环形队列的生产消费模型
linux·c语言·开发语言·c++·后端
一坨阿亮4 小时前
Linux 使用中的问题
linux·运维
dsywws5 小时前
Linux学习笔记之vim入门
linux·笔记·学习
幺零九零零6 小时前
【C++】socket套接字编程
linux·服务器·网络·c++
一个通信老学姐7 小时前
专业130+总400+武汉理工大学855信号与系统考研经验电子信息与通信工程,真题,大纲,参考书。
考研·信息与通信·信号处理·1024程序员节
小林熬夜学编程7 小时前
【Linux系统编程】第四十一弹---线程深度解析:从地址空间到多线程实践
linux·c语言·开发语言·c++·算法
力姆泰克8 小时前
看电动缸是如何提高农机的自动化水平
大数据·运维·服务器·数据库·人工智能·自动化·1024程序员节
力姆泰克8 小时前
力姆泰克电动缸助力农业机械装备,提高农机的自动化水平
大数据·服务器·数据库·人工智能·1024程序员节