sudo apt-get update
sudo apt-get install libsdl1.2-dev
sudo apt-get install libsdl-image1.2-dev
sudo apt-get install libsdl-ttf2.0-dev
sudo apt-get install libsdl-gfx1.2-dev
sudo apt-get install libsdl-mixer1.2-dev
结束后,在目录/usr/include中,就会有个SDL文件夹,包含所需要的头文件。
接下来可以简单测试一下。
#include "SDL.h"
#include "SDL_image.h"
#include "SDL_mixer.h"
#include "SDL_ttf.h"
#include <iostream>
int main()
{
int result = SDL_Init(SDL_INIT_EVERYTHING);
if(result == 0)
std::cout << "init success" << std::endl;
else
std::cout << "init fail" << std::endl;
SDL_Quit();
return 0;
}
编译命令如下:
g++ sdl_test.cpp `sdl-config --cflags --libs`
编译成功之后运行查看。