标签:sdl2开发环境搭建
SDL2开发环境搭建
开发环境
Visual studio 2012
Win8.1 64位
SDL2库及扩展库网址和下载库地址
SDL2库
http://www.libsdl.org/download-2.0.php
下载地址
http://www.libsdl.org/release/SDL2-devel-2.0.3-VC.zip
多通道音频混合器库
http://www.libsdl.org/projects/SDL_mixer/
下载地址
http://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-devel-2.0.0-VC.zip
图像文件加载库
http://www.libsdl.org/projects/SDL_image/
下载地址
http://www.libsdl.org/projects/SDL_image/release/SDL2_image-devel-2.0.0-VC.zip
请参照视频搭建SDL2的开发环境
分别将SDL、SDL_mixer和SDL_image库的32位版本库、64位版本库以及头文件进行拷贝
Include:C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include
32位dll(64位系统): C:\Windows\SysWOW64
64位dll(64位系统): C:\Windows\System32
32位dll(32位系统): C:\Windows\System32
32位lib(64位系统): C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib
64位lib(64位系统): C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib\amd64
在”属性->配置属性->链接器->输入->附加依赖项”添加SDL2.lib SDL2_mixer.lib SDL2_image.lib SDL2main.lib导入库。
在并在”属性->配置属性->C/C++->代码生成->运行库”选择” 多线程 DLL (/MD)”
以下为测试代码,当控制台打印“INFO: OK.”表明部署成功
#include <stdlib.h> #include <stdio.h> #include "SDL.h" #include "SDL_image.h" #include "SDL_thread.h" #include "SDL_mixer.h" #define BUFFER 1024 int main(int argc, char** argv) { int initted; SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); if (SDL_Init(SDL_INIT_EVERYTHING) == -1) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not initialize SDL."); exit(-2); } if (IMG_Init(IMG_INIT_PNG) == -1) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not initialize SDL IMG."); exit(-2); } initted = Mix_Init(0); initted = Mix_Init(~0); Mix_Quit(); if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, BUFFER) < 0) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Mix_OpenAudio ERROR."); exit(-2); } SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "OK."); Mix_CloseAudio(); IMG_Quit(); SDL_Quit(); return 0; }
标签:sdl2开发环境搭建
原文地址:http://quchenyong.blog.51cto.com/10723570/1696354