[英]I get error initializing SDL: No available video device using code compiled in cygwin using mingw
我在 windows 中運行它,使用 cygwin 和 mingw 編譯。
編譯命令:
g++ sdl.cpp -I"include" -L"lib" -lSDL2main -lSDL2 -lSDL2_image -o test.exe
代碼:
#include <SDL2/SDL.h>
int main(int argc, char *argv[])
{
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
printf("error initializing SDL: %s\n", SDL_GetError());
}
SDL_Window*win = SDL_CreateWindow("Test",SDL_WINDOWPOS_CENTERED,SDL_WINDOWPOS_CENTERED,1000, 1000, 0);
while (1);
return 0;
}
在 Cygwin 上:
g++ sdl.cpp -lSDL2main -lSDL2 -lSDL2_image -o test.exe
使用startxwin
運行 X 服務器,打開終端並
./test.exe
出現帶有白條的黑色 window。
由於您沒有處理事件,因此您需要硬殺來關閉程序
$ ps ax | grep test
18455 18448 18455 25368 pty3 197609 12:39:35 /tmp/test
$ kill -9 18455
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.