【转】Setting up SDL 2 on Code::Blocks 12.11
FROM: http://lazyfoo.net/tutorials/SDL/01_hello_SDL/windows/codeblocks/index.php
Setting up SDL 2 on Code::Blocks 12.11
Last Updated 9/17/13
1)First thing you need to do is download SDL headers, libary and binaries. You will find them on the SDL website, specifically on this page.
Since Code::Blocks comes with the MinGW compiler by default, odds are you'll want to download the MinGW development libraries.

Open the gzip archive and there should be a tar archive. Open up the tar archive and the should be a folder called SDL2-2.something.something. In side of that folder there should be a bunch of folders and files, most importantly i686-w64-mingw32 which contains the 32bit library and x86_64-w64-mingw32 which contains the 64bit library.
This is important: most compilers still compile 32bit binaries by default to maximize compatibility. We will be using the 32bit binaries for this tutorial set. It doesn't matter if you have a 64bit operating system, since we are compiling 32bit binaries we will be using the 32bit library.
Inside of i686-w64-mingw32 are the include, lib, and bin folders which contain everything we need compile and run SDL applications. Copy the contents of i686-w64-mingw32 to any directory you want. I recommend putting it in a folder that you dedicate to holding all your development libraries for MinGW. For these tutorials I'm putting it in a directory I created C:\mingw_dev_lib
2)Start up Code::Blocks and create a new empty project.

3)Go to project properties.

4)Now we have to tell Code::Blocks to search for header files in the library folder we just extracted. Go to build options.

In the Search Directories, we need to add a new compiler directory. Click add, Select the SDL2 folder inside of the include directory from the folder we extracted. Say no when it asks you whether you want it to be a relative path. Now Code::Blocks knows where to find the SDL 2 header files.

If you get an error where the compiler says it can't find SDL.h, it means you messed up this step.
5)Next we are going to tell Code::Blocks to search for library files in the SDL folder we just extracted. All you have to is go to the linker tab and add the lib directory from the folder we extacted to the linker search directories.

If you get an error where the linker complains it can't find -lSDL2 or -lSDL2main, it means you messed up this step.
6)In order to compile SDL 2 code, we have to tell the compiler to link against the libraries. Go under Linker Settings and paste
-lmingw32 -lSDL2main -lSDL2

7)Go back to the project properites and under Build Targets select the build type.

8)When our SDL 2 application runs, the operating system needs to be able to find the dll file.
Go find the SDL 2 folder you extracted and from the bin folder inside copy SDL2.dll and put it either where your executable will run, or inside of the system directory. C:\WINDOWS\SYSTEM32 is the 32bit windows system directory and C:\Windows\SysWOW64 is the 64bit system directory of 32bit applications. For these tutorials, I'm assuming we're making 32bit applications. If you get an error when you run the program where it complains that it can't find SDL2.dll, it means you messed up this step.
9)Now go download the source for lesson 01. Add the source files inside to your project.
Now build. If there are any errors, make sure you didn't skip a step.
Now that you have SDL 2 compiling, it time to go onto part 2 of the tutorial.
【转】Setting up SDL 2 on Code::Blocks 12.11的更多相关文章
- 【转】Setting up SDL Extension Libraries on Code::Blocks 12.11
FROM: http://lazyfoo.net/tutorials/SDL/06_extension_libraries_and_loading_other_image_formats/window ...
- Code::Blocks
Code::Blocks 是一个开放源码的全功能的跨平台C/C++集成开发环境. Code::Blocks是开放源码软件.Code::Blocks由纯粹的C++语言开发完成,它使用了著名的图形界面库w ...
- 【转】Setting up SDL Extension Libraries on Windows
FROM: http://lazyfoo.net/tutorials/SDL/06_extension_libraries_and_loading_other_image_formats/window ...
- 【转】Setting up SDL on Windows
FROM: http://lazyfoo.net/tutorials/SDL/01_hello_SDL/windows/index.php Setting up SDL on Windows Last ...
- 【转】Setting up SDL 2 on MinGW
FROM: http://lazyfoo.net/tutorials/SDL/01_hello_SDL/windows/mingw/index.php Setting up SDL 2 on MinG ...
- Code::Blocks配置GTK+2和GTK+3
Code::Blocks配置GTK+2和GTK+3 作者 He YiJun – storysnail<at>gmail.com 团队 ls 版权 转载请保留本声明! 本文档包含的原创代码根 ...
- 【转】Setting up SDL 2 on Visual Studio 2010 Ultimate
from: Lazy Foo'Productions - Setting up SDL 2 on Visual Studio 2010 Ultimate 1)First thing you need ...
- code::Blocks生成的dll 在 java jni 调用遇到的问题
Test.java__________________________________ public class Test{ public static native void p(); pub ...
- 编译Code::Blocks源码 with MinGW on Win
Build Code::Blocks源码 ---By 狂徒归来 CodeBlocks是一款非常优秀的IDE !可惜的是没有64位的版本,而且本来是轻量级别的IDE就应该够轻,能够像记事本工具一样,迅速 ...
随机推荐
- Centos-bzip2压缩文件-bzip2 bunzip2
bzip2 buzip2 对文件进行压缩与解压缩,类似 gzip gunzip命令,只能压缩文件,对目录则压缩目录下文件,生成以 .bz2为扩展名的文件 相关选项 -d 解压 -v 压缩或解压显示详细 ...
- Layman H5+Webapp+MUI App 页面滑至到底部自动加载新的内容
要点:使用jquery的scroll()方法实现,当用户滚动指定的元素时,会发生 scroll 事件 scroll 事件适用于所有可滚动的元素和 window 对象(浏览器窗口) scroll() 方 ...
- Java知识系统回顾整理01基础03变量01变量定义
定义: 变量:用来命名一个数据的标识符 一.什么是变量? 用具体实例定义变量 变量的定义是: 用来命名一个数据的标识符 1949 这是一个数字,代表某年 如果要命名这个数字,在java里就会写成: i ...
- Mac系统下的zip压缩包解压到Windows下出现乱码的解决方法
环境变量 环境变量是具有特殊名字的一个特定对象,包含了一个或多个应用程序运行所需的信息.(例如PATH,可执行程序的搜索路径,当要求系统运行一个程序,而没告诉系统它的具体路径时,系统就要在PTAH值的 ...
- CString类常用方法----Left(),Mid(),Right()
参考:https://blog.csdn.net/Qingqinglanghua/article/details/4992624 CString Left( int nCount ) const; ...
- c++ 中. 和 ->,波浪号 ~ 符号怎么用 ————很重要
参考:https://www.cnblogs.com/Simulation-Campus/p/8809999.html 1. 用在类中的析构函数之前,表示该函数是析构函数.如类A的析构函数 clas ...
- ng2 父子组件传值 - 状态管理
一. 父子组件之间进行直接通话 //父组件html <ul> <app-li [value] = "value" (liClick) = "liClic ...
- ScanTailor-ScanTailor 强大的多方位的满足处理扫描图片的需求
ScanTailor 强大的多方位的满足处理扫描图片的需求 ScanTailor 能做什么? 批量或单张或选择区间旋转图片 自动切割页面,同时提供手动选项 自动识别图像歪斜角度,同时提供手动选项 ...
- docker-搭建 kafka+zookeeper集群
拉取容器 docker pull wurstmeister/zookeeper docker pull wurstmeister/kafka 这里演示使 ...
- spring boot:实现图片文件上传并生成缩略图(spring boot 2.3.1)
一,为什么要给图片生成缩略图? 1, 用户上传的原始图片如果太大,不能直接展示在网站页面上, 因为不但流费server的流量,而且用户打开时非常费时间, 所以要生成缩略图. 2,服务端管理图片要注意的 ...