【转】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就应该够轻,能够像记事本工具一样,迅速 ...
随机推荐
- java安全编码指南之:敏感类的拷贝
目录 简介 一个简单的SensitiveObject SensitiveObject的限制 对SensitiveObject的攻击 解决办法 简介 一般来说class中如果包含了私有的或者敏感的数据的 ...
- RabbitMq如何确保消息不丢失
上篇写了掌握Rabbitmq几个重要概念,从一条消息说起,这篇来总结关于消息丢失让人头痛的事情.网络故障.服务器重启.硬盘损坏等都会导致消息的丢失.消息从生产到消费主要结果以下几个阶段如下图. ①生产 ...
- VS2010,VS2012,VS2013,VS2015等的自动提示不能默认选中的功能解决办法
很简单,只需要按 ctrl+alt+space 即可切换.
- 【CF1425A】 Arena of Greed题解
原题链接 简要翻译: Mr.Chanek与另一个人玩一个取硬币游戏,他先手.玩家在自己的回合内可以取走硬币堆中的一个.如果硬币堆里有偶数个硬币,玩家也可以选择取走硬币总数的一半.两名玩家都是绝对聪明的 ...
- React学习小记--setState的同步与异步
react中,state不能直接修改,而是需要使用setState()来对state进行修改,那什么时候是同步而什么时候是异步呢? 基础代码: setCounter = (v) => { thi ...
- 分享一些比较好用的(免费)网站及推荐理由 SMARK
分享一些比较好用的(免费)网站及推荐理由 --By SMARK 资源类 这里面是一些有供下载的资源的网站等 视频 片库 内容怎么样有待考证 蓝光网 看着还行, 打赏收入 预告片世界 还行, 收入有待考 ...
- Spring中用@DependsOn注解控制Bean的创建顺序
1. 概述 Spirng容器自己会管理bean的生命周期和bean实例化的顺序,但是我们仍然可以根据我们自己的需求进行定制.我可以可以选择使用SmartLifeCycle接口,也可以用@Depends ...
- C++中cout.setf()和cout.precision()
这两个就是格式控制的~ostream成员函数里面的,也可以用输出流操作符来控制,都一样的~附给你一些看看~ 其中cout.setf跟setiosflags一样的,cout.precision跟setp ...
- 跟我一起学.NetCore之WebApi接口裸奔有风险(Jwt)
前言 撸码需谨慎,裸奔有风险.经常在一些技术交流群中了解到,还有很多小伙伴的项目中Api接口没有做任何安全机制验证,直接就裸奔了,对于一些临时项目或是个人小项目还好,其余的话,建议小伙伴们酌情考虑都加 ...
- idea 2020.1 Mybatis log plugin破解插件
下载 链接: https://pan.baidu.com/s/1FTgtJiyzxxaNxWLyX4OgZw 密码: w7w8 idea安装本地插件