c++ - SDL 中没有可用的视频设备
问题描述
我使用的 SDL-2 库是从源代码编译的。
每当我尝试在 X11 上运行任何使用 SDL-2 的程序时,都会出现以下错误:
SDL_Init Error: No available video device
我在 Linux Mint 19.3 Tricia 上通过命令行运行这些程序。
这是./configure
摘要:
SDL2 Configure Summary:
Building Shared Libraries
Building Static Libraries
Enabled modules : atomic audio video render events joystick haptic sensor power filesystem threads timers file loadso cpuinfo assembly
Assembly Math : mmx 3dnow sse sse2 sse3
Audio drivers : disk dummy oss
Video drivers : dummy opengl_es2 vulkan
Input drivers : linuxev linuxkd
Using libsamplerate : NO
Using libudev : NO
Using dbus : NO
Using ime : YES
Using ibus : NO
Using fcitx : NO
解决方案
看起来您的 SDL 构建缺少 X11 后端。
Mint 看起来足够 Debian-y,sudo apt build-dep libsdl2
应该引入所需的-dev
软件包。然后您可以重新运行./configure
和重建/重新安装 SDL。
确保仔细检查摘要中的Video drivers
行configure
是否包含您有兴趣使用的后端。
如果该build-dep
方法过于手动,则docs/README-linux.md
有一个(有点旧的)逐项列出的-dev
包列表:
================================================================================ Build Dependencies ================================================================================ Ubuntu 13.04, all available features enabled: sudo apt-get install build-essential mercurial make cmake autoconf automake \ libtool libasound2-dev libpulse-dev libaudio-dev libx11-dev libxext-dev \ libxrandr-dev libxcursor-dev libxi-dev libxinerama-dev libxxf86vm-dev \ libxss-dev libgl1-mesa-dev libesd0-dev libdbus-1-dev libudev-dev \ libgles1-mesa-dev libgles2-mesa-dev libegl1-mesa-dev libibus-1.0-dev \ fcitx-libs-dev libsamplerate0-dev libsndio-dev Ubuntu 16.04+ can also add "libwayland-dev libxkbcommon-dev wayland-protocols" to that command line for Wayland support. NOTES: - This includes all the audio targets except arts, because Ubuntu pulled the artsc0-dev package, but in theory SDL still supports it. - libsamplerate0-dev lets SDL optionally link to libresamplerate at runtime for higher-quality audio resampling. SDL will work without it if the library is missing, so it's safe to build in support even if the end user doesn't have this library installed. - DirectFB isn't included because the configure script (currently) fails to find it at all. You can do "sudo apt-get install libdirectfb-dev" and fix the configure script to include DirectFB support. Send patches. :)
推荐阅读
- devexpress - 在一个 xtrareport 中创建多个图表
- dataframe - 将 pyspark Dataframe 写入具有相同列数和一个额外的 autoIncrement 列的雪花表中
- multithreading - 重置代码
- reactjs - 如何为 React 应用程序配置 Rollup?
- sql - Oracle case 缺少关键字
- python - TypeError:blit 的目标位置无效
- amazon-web-services - 哪个 AWS 托管策略包含创建 EKS 集群的权限?
- javascript - 加载组件未在 React.js 表单组件中呈现?
- java - 使用 JPA 使用本机查询填充 DTO
- android - 如何从另一个列表中的列表中拯救项目