当我尝试运行我的程序时,出现以下错误信息:
SDL2库已正确链接到我的C项目中。
SDL could not initialize! SDL_Error: No available video device
我已经安装了所有必要的SDL库,并且当前正在运行ubuntu 15.10。
这是我的简单SDL代码:
#include <stdio.h>
#include "SDL2/SDL.h"
//Screen dimension constants
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;
int main(int argc, char* argv[])
{
//The window we'll be rendering to
SDL_Window* window = NULL;
//The surface contained by the window
SDL_Surface* screenSurface = NULL;
//Initialize SDL
if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
{
printf("SDL could not initialize! SDL_Error: %s\n", SDL_GetError());
}
else
{
//Create window
window = SDL_CreateWindow("SDL Tutorial",SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH,
SCREEN_HEIGHT, SDL_WINDOW_SHOWN);
if (window == NULL) {
printf("Window could not be created! SDL_Error: %s\n", SDL_GetError());
}
}
return 0;
}
SDL2库已正确链接到我的C项目中。