c++ - 加载共享库时出错:libSDL2-2.0.so.0
问题描述
我无法加载动态 SDL2 库。有这个简单的代码:
#include <iostream>
#include <SDL2/SDL.h>
using namespace std;
int main()
{
if (!SDL_Init(SDL_INIT_VIDEO))
{
cout << "ok";
}
}
并在此目录中有dll:
user@Host:~/Desktop/bin$ ls /usr/local/lib
cmake libSDL2.a libSDL2main.la libSDL2_test.la
libSDL2-2.0.so.0 libSDL2.la libSDL2.so pkgconfig
libSDL2-2.0.so.0.12.0 libSDL2main.a libSDL2_test.a python3.8
当编译为
user@Host:~/Desktop/bin$ g++ -I/usr/local/lib a.cpp -lSDL2 -lSDL2main
user@Host:~/Desktop/bin$ ./a.out
./a.out: error while loading shared libraries: libSDL2-2.0.so.0: cannot open shared object file: No such file or directory
PS:我已经从 tar https://www.libsdl.org/download-2.0.php手动安装了 SDL2,而不是通过dpkg
,所以我不得不./config; make all; make install
在 untared 目录中。由于以下错误,该软件包libsdl2-dev
无法安装:
Err http://cz.archive.ubuntu.com/ubuntu focal-updates/main amd64 libasound2-dev amd64 1.2.2-2.1ubuntu2
404 Not Found [IP: 2001:67c:1360:8001::24 80]
Err http://cz.archive.ubuntu.com/ubuntu focal-updates/main amd64 zlib1g-dev amd64 1:1.2.11.dfsg-2ubuntu1.1
404 Not Found [IP: 2001:67c:1360:8001::24 80]
Err http://cz.archive.ubuntu.com/ubuntu focal-updates/main amd64 libudev-dev amd64 245.4-4ubuntu3.2
404 Not Found [IP: 2001:67c:1360:8001::24 80]
98% [Working]E: Failed to fetch http://cz.archive.ubuntu.com/ubuntu/pool/main/a/alsa-lib/libasound2-dev_1.2.2-2.1ubuntu2_amd64.deb: 404 Not Found [IP: 2001:67c:1360:8001::24 80]
E: Unable to fetch some packages; try '-o APT::Get::Fix-Missing=true' to continue with missing packages
但是现在手动安装了库和头文件,我怎样才能将它们从/usr/local/lib
?
PS2:
user@Host:~/Desktop/script$ uname -a
Linux Host 5.4.0-52-generic #57-Ubuntu SMP Thu Oct 15 10:57:00 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
解决方案
推荐阅读
- algorithm - 如何可视化 3 路归并排序?
- swift - 意外发现nil,但是vars不是nil
- kubernetes - 在 Kubernetes CronJob 中运行 `find` 命令
- google-pagespeed - 如何测量登录后出现的页面的页面速度
- kotlin - 不能在 kotlin 中使用 observableArrayList 作为 hashmap 的值
- spring-boot - Spring Boot - `management.endpoint.env.post.enabled` 的新属性名称是什么
- java - 防止 JOption 阻塞子 JFrame
- sql - SQL 从几行中获取总计,直到用完
- python - 学习 Python:模板和网页(powershell 中的错误)[$:无法识别术语“$”]
- ubuntu - docker-for-windows 和 WSL2 之间的端口映射是如何完成的?