I cannot use SDL2 on centOS , maybe I install it failed. error:No available video device

I cannot use SDL2 on centOS , maybe I install it failed. error:No available video device

我的系统是centOS 6.5。我从官方网站下载了 SDL 2.0.4 版。然后我一步一步地配置、制作、安装依赖于SDL Wiki。 有一个配置列表:


SDL2 Configure Summary:
Building Shared Libraries
Building Static Libraries
Enabled modules : atomic audio video render events joystick haptic      power filesystem threads timers file loadso cpuinfo assembly
Assembly Math   : mmx 3dnow sse sse2
Audio drivers   : disk dummy oss
Video drivers   : dummy
Input drivers   : linuxev linuxkd
Using libudev   : YES
Using dbus      : NO
Using ibus      : NO

我是新手,所以可能会像视频驱动程序一样有问题:dummy ?
我不知道,我继续安装,make 和 make install。 然后我尝试通过下载名为 Hello_SDL 的 lazy foo 教程的第一个程序来编译 && 运行 第一个程序。通过使用这个命令

g++ 01_hello_SDL.cpp -w  -o 01_hello_SDL  `sdl2-config --cflags --libs`

编译成功!但是当我 运行 二进制文件时,它报告错误: SDL 无法初始化! SDL_Error: 没有可用的视频设备 这太糟糕了。我 google 这个错误并尝试这些方法:

  1. 导出SDL_VIDEODRIVER=X11

  2. 显示=:0 ;导出显示

  3. 关闭 GUI : vi /etc/inittab 更改为 id:3:initdefault:

以上方法未使用。我被逼疯了,我的第一个 SDL 程序仍然不能 运行。谁能帮我 ?我是否需要重新安装 X11 以及如何在 centOS 上安装它?

确保在 运行 configure.

之前安装了合适的开发库

在 Debian 和衍生版上,您可以通过 apt-get build-dep libsdl2 来实现。我不确定 CentOS 上的类似程序是什么,粗略的谷歌搜索建议 yum-builddep SDL2 作为一种可能性。

您需要安装X11开发包。

我在 CentOS 5.10 上开发我的 SDL2 游戏并且它可以运行,但你应该知道 SDL2 中没有对 CentOS 5/6 的开箱即用 joystick/gamepad 支持。

su
yum groupinstall "X Software Development"

或在 Whosebug 上查看:

Development packages for X11 for CentOS