#include "SDL.h"/* 脣脱碌胫DL鲁脤貌猫脪脠 */
#include <stdio.h>
int main()
{
printf("Initializing SDL.\n") /* 鲁玫炉Video脱Audio */
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO)==-1)
{
printf("Could not initialize SDL: %s.\n",SDL_GetError())
exit(-1)
}
printf("SDL initialized.\n")
printf("Quiting SDL.\n")
SDL_Quit()
printf("Quiting...\n")
exit(0)
}
测试结:Initializing SDL.
SDL initialized.
Quiting SDL.
Quiting...
面调用ffplay "数据源"现:
FFplay version SVN-r26402, Copyright (c) 2003-2011 the FFmpeg developers
built on Apr 13 2012 18:37:31 with gcc 4.3.2
configuration: --prefix=/usr --enable-gpl --enable-shared --enable-pthreads --enable-libx264 --enable-ffserver --enable-ffplay --disable-yasm
libavutil 50.36. 0 / 50.36. 0
libavcore 0.16. 1 / 0.16. 1
libavcodec 52.108. 0 / 52.108. 0
libavformat 52.93. 0 / 52.93. 0
libavdevice 52. 2. 3 / 52. 2. 3
libavfilter 1.74. 0 / 1.74. 0
libswscale 0.12. 0 / 0.12. 0
Could not initialize SDL - No available video device
电脑是win7 64位, Dev-Cpp安装路径是C:\Dev-Cpp,此目录下有 MinGW64,即windows版GCC的根目录。下载SDL
打开 http://www.libsdl.org/download-2.0.php
找到开发库Windows下 SDL2-2.0.3-mingw.tar.gz 点击下载。
也可以直接点击 http://www.libsdl.org/release/SDL2-devel-2.0.3-mingw.tar.gz
因为前面Dev-Cpp中装是MinGW64,所以解压后进入SDL开发库中的 x86_64-w64-mingw32目录
将 F:\Downloads\SDL2-2.0.3\x86_64-w64-mingw32\include\SDL2 下所有头文件复制到 C:\Dev-Cpp\MinGW64\x86_64-w64-mingw32\include;
再将 F:\Downloads\SDL2-2.0.3\x86_64-w64-mingw32\lib 所有 lib* 文件复制到 C:\Dev-Cpp\MinGW64\x86_64-w64-mingw32\lib
==========================================================================================
接下来创建一个测试程序。
在Dev-Cpp中创建一个C项目, 添加main.c
[cpp] view plaincopy
#include <stdio.h>
#include <stdlib.h>
#include <SDL.h>
int main(int argc, char * argv[])
{
if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO)==-1)
{
fprintf(stderr, "SDL_Init() failed")
exit(-1)
}
printf("SDL_init() success")
SDL_Quit()
return 0
}
配置项目需要链接的库 -lmingw32 -lSDL2main -lSDL2
完了可以正常编译,但是运行失败,这是由于运行时找不SDL2.dll。
把 F:\Downloads\SDL2-2.0.3\x86_64-w64-mingw32\bin\SDL2.dll 复制到 C:\Windows\System32\目录下,或者是把这个SDL2.dll复制到 编译生成的exe文件所在目录。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)