在 Linux 上安装 SDL2
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21588379/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Installing SDL2 on Linux
提问by exebook
I try to run simple test.cpp from Twinklebar SDL tutorial, I get this error:
我尝试从 Twinklebar SDL 教程中运行简单的 test.cpp,出现此错误:
test.cpp:2:10: fatal error: 'SDL2/SDL.h' file not found
So I look up the sdl development package in Ubuntu/Mint:
于是我在 Ubuntu/Mint 中查找 sdl 开发包:
aptitude search sdl | grep 2
All I can find is this:
我能找到的只有这个:
libsdl1.2-dev
Does this mean my only option is to install from sources?
这是否意味着我唯一的选择是从源代码安装?
采纳答案by Leonardo
It depends which Ubuntu version you are running but yes, there is a libsdl2 package for Ubuntu: http://packages.ubuntu.com/search?keywords=sdl2
这取决于您运行的是哪个 Ubuntu 版本,但是是的,Ubuntu 有一个 libsdl2 包:http://packages.ubuntu.com/search?keywords=sdl2
The package you want is called libsdl2-dev
.
你想要的包叫做libsdl2-dev
.
Also, about the #include <SDL/SDL.h>
line, it seems the recommended way doing it is by adjusting your compiler flags to add SDL's include pah and use #include "SDL.h"
. See https://forums.libsdl.org/viewtopic.php?t=5997for more details on that.
此外,关于该#include <SDL/SDL.h>
行,似乎推荐的方法是调整编译器标志以添加 SDL 的 include pah 和 use #include "SDL.h"
。有关更多详细信息,请参阅https://forums.libsdl.org/viewtopic.php?t=5997。