ubuntu上安装SDL2

转载 2018年04月16日 20:11:26
执行这两个命令就可以了
sudo apt-get install libsdl2-2.0

sudo apt-get install libsdl2-dev

引用SDL2库编译自己的程序
gcc -o myprogram myprogram.c `sdl2-config --cflags --libs`


以下摘自官网

https://wiki.libsdl.org/Installation

Supported platforms

Linux/Unix

Several other platforms will be built "the Unix way," so we'll describe this platform first.

SDL supports most popular flavors of Unix: Linux 2.6+, the various BSDs (FreeBSD, NetBSD, OpenBSD), Solaris, and other things like them.

First! Do you need to compile SDL yourself? It's possible your distribution's package manager already did it for you!

Debian-based systems (including Ubuntu) can simply do "sudo apt-get install libsdl2-2.0" to get the library installed system-wide, and all sorts of other useful dependencies, too. "sudo apt-get install libsdl2-dev" will install everything necessary to build programs that use SDL. Please see docs/README-linux.md for a more complete discussion of packages involved.

Red Hat-based systems (including Fedora) can simply do "sudo yum install SDL2" to get the library installed system-wide, or "sudo yum install SDL2-devel" to get headers and other build requirements ready for compiling your own SDL programs.

Gentoo users can "sudo emerge libsdl2" to get everything they need.

If you're compiling SDL yourself, here's what we refer to as "the Unix way" of building:


If you're compiling SDL yourself, here's what we refer to as "the Unix way" of building:

  • Get a copy of the source code, either from Mercurial or an official tarball or whatever.
  • Make a separate build directory (SDL will refuse to build in the base of the source tree).
  • Run the configure script to set things up.
  • Run "make" to compile SDL.
  • Run "make install" to install your new SDL build on the system.

This looks something like this:

hg clone https://hg.libsdl.org/SDL SDL
cd SDL
mkdir build
cd build
../configure
make
sudo make install

The last command says "sudo" so we can write it to /usr/local (by default). You can change this to a different location with the --prefix option to the configure script. In fact, there are a LOT of good options you can use with configure! Be sure to check out its --help option for details. SDL tries to do the right thing by default, though, so you can usually get away with no options at all. "make" could be "make -j4" or whatever if you have more than one CPU; SDL can safely be built in parallel across all the CPU cores you have available to you. A good rule of thumb for Linux is the number of cores plus two, so you use all the processing resources possible, and if a process or two is competing for the disk, those two extra jobs might be able to put the otherwise-idle CPU cores to work in the meantime (so on a four-core system? Try "make -j6".)

An (experimental!) alternative to the configure script is the CMake project file. It works on similar principles to the configure script, but you might find that you enjoy it more, if this is the sort of thing you generally enjoy in the first place. Driving that is left as an exercise for the reader.

Once you have the library installed, you can use the sdl2-config program to help you compile your own code:

  • gcc -o myprogram myprogram.c `sdl2-config --cflags --libs`

转载地址: https://blog.csdn.net/zhouzhenhe2008/article/details/54428761

Ubuntu14.04下C++开发SDL2应用

针对SDL 2.0的C++编程,以一个显示图像为例,详细讲解了库的安装过程、编译脚本和系统动态库路径的修改方法。...
  • alaclp
  • alaclp
  • 2015-01-16 00:13:00
  • 1628

Ubuntu Linux下SDL2安装

Ubuntu linux 14.0下安装和使用SDL2
  • hank12580
  • hank12580
  • 2015-05-24 08:56:41
  • 3757

Linux 下SDL2 image安装及使用

1. 安装SDL image 2.0 sudo apt-get install libsdl2-image-dev 如果没有安装过SDL2 ,应该会自动安装,也可以自己安装 sudo apt-get...
  • hank12580
  • hank12580
  • 2015-05-24 10:08:57
  • 3045

ubuntu下学习SDL2

昨天Ubuntu更新,把系统搞挂了.索性直接上了最新的Xubuntu16.04.正好打算在暑假学习一下SDL2,后面利用SDL2实现一个软件渲染器. 首先装上必备的东西 sudo apt-get in...
  • victo2012
  • victo2012
  • 2016-07-02 18:02:41
  • 1070

ubuntu Linux下Codeblocks编译 SDL2.0工程

Linux下Codeblocks编译 SDL2.0工程 CodeBlocks工程模板有SDL1.2工程,若仅添加:#include 还是无法编译SDL2.0工程。 解决办法: Codeblocks ...
  • yTexas
  • yTexas
  • 2016-05-09 00:14:57
  • 351

SDL2.0在Ubuntu14.04下的安装及测试

安装环境 系统 :Ubuntu 14.04 方式:编译源代码的方式 SDL版本:SDL2-2.0.3(下载) 安装步骤 (1)...
  • tkp2014
  • tkp2014
  • 2015-01-11 20:28:21
  • 2370

linux 下 SDL2 安装

1 SDL2-2.0.3 下载  http://www.libsdl.org/ 解压   配置安装环境(--prefix=/usr 安装到/usr下以便能直接调用) ./configure ...
  • RoiSolitaire
  • RoiSolitaire
  • 2015-03-05 13:46:52
  • 770

Linux下编译安装SDL2.0

  • 2014年11月07日 16:16
  • 23KB
  • 下载

ubuntu 14.04 LTS编译基于ffmpeg+sdl2.0的简单播放器

ubuntu 14.04 LTS编译基于ffmpeg+sdl2.0的简单播放器 概要 我刚开始进入ffmpeg领域学习,最近参考最简单的基于FFMPEG+SDL的视频播放器 ver2 (采用SDL...
  • zousimaiji
  • zousimaiji
  • 2016-04-09 11:02:13
  • 803

SDL2在MAC OS X 10.9/10.10 XCode 5下的配置安装

近日试着在XCode5下使用SDL2.0。 从官网直接下载dmg,将SDL2.frameworks文件复制到/Library/Frameworks下,之后在XCode中导入,即便什么也不做,只是默认...
  • xiaokaneier
  • xiaokaneier
  • 2014-08-05 14:54:02
  • 3832
收藏助手
不良信息举报
您举报文章:ubuntu上安装SDL2
举报原因:
原因补充:

(最多只允许输入30个字)