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
into the other linker options field and click OK.
If you get an error where the linker complains about a bunch of undefined references, it means you messed up this step.

7)Go back to the project properites and under Build Targets select the build type.
You can set it to GUI Application if you don't want console output, and Console Application if you do want console output. For this tutorial set, errors will be printed on the console, so I recommend leaving it as a console application as you are still learning and prototyping.

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的更多相关文章

  1. 【转】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 ...

  2. Code::Blocks

    Code::Blocks 是一个开放源码的全功能的跨平台C/C++集成开发环境. Code::Blocks是开放源码软件.Code::Blocks由纯粹的C++语言开发完成,它使用了著名的图形界面库w ...

  3. 【转】Setting up SDL Extension Libraries on Windows

    FROM: http://lazyfoo.net/tutorials/SDL/06_extension_libraries_and_loading_other_image_formats/window ...

  4. 【转】Setting up SDL on Windows

    FROM: http://lazyfoo.net/tutorials/SDL/01_hello_SDL/windows/index.php Setting up SDL on Windows Last ...

  5. 【转】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 ...

  6. Code::Blocks配置GTK+2和GTK+3

    Code::Blocks配置GTK+2和GTK+3 作者 He YiJun – storysnail<at>gmail.com 团队 ls 版权 转载请保留本声明! 本文档包含的原创代码根 ...

  7. 【转】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 ...

  8. code::Blocks生成的dll 在 java jni 调用遇到的问题

    Test.java__________________________________ public class Test{    public static native void p(); pub ...

  9. 编译Code::Blocks源码 with MinGW on Win

    Build Code::Blocks源码 ---By 狂徒归来 CodeBlocks是一款非常优秀的IDE !可惜的是没有64位的版本,而且本来是轻量级别的IDE就应该够轻,能够像记事本工具一样,迅速 ...

随机推荐

  1. spring in action-note-2

    1.AOP:在软件业,AOP为Aspect Oriented Programming的缩写,意为:面向切面编程,通过预编译方式和运行期动态代理实现程序功能的统一维护的一种技术.AOP是OOP的延续,是 ...

  2. (一)jenkins+git+docker

    目录 一.发布流程设计 1.工作流程 2.环境规划如下 二.部署Git仓库 1.创建Git用户并设置密码 2.创建仓库 3.免密访问 4.在jenkins那台机上做ssh认证 三.准备Jenkins环 ...

  3. 基础篇:详解JAVA对象实例化过程

    目录 1 对象的实例化过程 2 类的加载过程 3 触发类加载的条件 4 对象的实例化过程 5 类加载器和双亲委派规则,如何打破双亲委派规则 欢迎指正文中错误 关注公众号,一起交流 参考文章 1 对象的 ...

  4. Python-列表 元组-list tuple

    列表 list [vale,...] 可加入任意类型数据,并可嵌套,不定长 student = ["beimenchuixue", "maYun", " ...

  5. 剑指offer-二叉树

    1. 平衡二叉树 输入一棵二叉树,判断该二叉树是否是平衡二叉树. 解: 要么是一颗空树,要么左右子树都是平衡二叉树且左右子树深度之差不超过1 1 # class TreeNode: 2 # def _ ...

  6. 第二次UML作业

    博客班级 https://edu.cnblogs.com/campus/fzzcxy/2018SE1/ 作业要求 https://edu.cnblogs.com/campus/fzzcxy/2018S ...

  7. JavaFX FileChooser文件选择器,缓存上一次打开的目录

    例1:点击按钮Choose File打开文件选择器,并打开指定的目录.这是通过final void setInitialDirectory(final File value)方法实现的. 1 impo ...

  8. 跟我一起学.NetCore之WebApi接口裸奔有风险(Jwt)

    前言 撸码需谨慎,裸奔有风险.经常在一些技术交流群中了解到,还有很多小伙伴的项目中Api接口没有做任何安全机制验证,直接就裸奔了,对于一些临时项目或是个人小项目还好,其余的话,建议小伙伴们酌情考虑都加 ...

  9. Go strconv包

    strconv包 该包主要实现基本数据类型与其字符串表示的转换. 常用函数为Atoi().Itia().parse系列.format系列.append系列. 更多函数请查看官方文档. string与i ...

  10. js 基础概念

    一 执行上下文 和 执行上下文栈 执行上下文:一段javascript代码执行前的准备工作 问题一:js引擎遇到怎样一段代码才会做"准备工作呢"? 可执行代码类型:全局代码.函数代 ...