FROM:http://lazyfoo.net/tutorials/SDL/06_extension_libraries_and_loading_other_image_formats/windows/mingw/index.php

Setting up SDL Extension Libraries on MinGW

Last Updated 6/21/14

1)First thing you need to do is download SDL_image headers and binaries. You will find them on the SDL_image website, specifically on this page.

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_image-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.

2)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

3)Now go download the source for lesson 06. Extract the source somewhere and compile by entering this big old command (This command assumed you have SDL_image extracted at C:\mingw_dev_lib):

g++ 06_extension_libraries_and_loading_other_image_formats.cpp -IC:\mingw_dev_lib\include\SDL2 -LC:\mingw_dev_lib\lib -w -Wl,-subsystem,windows -lmingw32 -lSDL2main -lSDL2 -lSDL2_image -o 06_extension_libraries_and_loading_other_image_formats

If you're using a makefile, you can just change the values of some of the macros:

From Makefile

#OBJS specifies which files to compile as part of the project
OBJS = 06_extension_libraries_and_loading_other_image_formats.cpp #CC specifies which compiler we're using
CC = g++ #INCLUDE_PATHS specifies the additional include paths we'll need
INCLUDE_PATHS = -IC:\mingw_dev_lib\include\SDL2 #LIBRARY_PATHS specifies the additional library paths we'll need
LIBRARY_PATHS = -LC:\mingw_dev_lib\lib #COMPILER_FLAGS specifies the additional compilation options we're using
# -w suppresses all warnings
# -Wl,-subsystem,windows gets rid of the console window
COMPILER_FLAGS = -w -Wl,-subsystem,windows #LINKER_FLAGS specifies the libraries we're linking against
LINKER_FLAGS = -lmingw32 -lSDL2main -lSDL2 -lSDL2_image #OBJ_NAME specifies the name of our exectuable
OBJ_NAME = 06_extension_libraries_and_loading_other_image_formats #This is the target that compiles our executable
all : $(OBJS)
$(CC) $(OBJS) $(INCLUDE_PATHS) $(LIBRARY_PATHS) $(COMPILER_FLAGS) $(LINKER_FLAGS) -o $(OBJ_NAME)

As you can see it was as easy as changing the file name of the source and executable and adding

-lSDL2_image

to the linker. If we were linking SDL_ttf, we'd add

-lSDL2_ttf

and for SDL_mixer we'd put:

-lSDL2_mixer

Now that you have the extension library compiling, it's time to go onto part 2 of the tutorial.

  

最新文章

  1. 十大关系数据库SQL注入工具一览
  2. 谷歌、百度、1万ip能赚多少钱?1000IP能够值多少钱呢?
  3. Power-BI 主要城市商品房销售分析
  4. 多线程编程3 - NSOperationQueue
  5. 《Code Complete》ch.26 代码调整技术
  6. *ecshop 首页促销价显示倒计时
  7. 树莓派 安装 php
  8. xdebug初步
  9. mysql服务器的常规操作
  10. 218. The Skyline Problem
  11. 1个小时学会ReactiveCocoa基本使用
  12. 成都Python工程师招聘
  13. racle undo 解析
  14. 【floyd】 poj 2240
  15. GIT常用命令(图片版)
  16. Entity Framework入门教程(2)---EF工作流程
  17. docker:学习笔记
  18. Nginx http相关常用配置总结
  19. 【Gym - 100947G】Square Spiral Search
  20. idea 报错 :error:java:Compilation failed:internal java compiler error

热门文章

  1. luogu2756 飞行员配对方案问题 (裸匈牙利)
  2. 微服务实战系列(五)-注册中心Eureka与nacos区别
  3. 树(二叉树 & 二叉搜索树 & 哈夫曼树 & 字典树)
  4. 日志分析平台ELK之搜索引擎Elasticsearch集群
  5. 编写自己的Arduino库
  6. 题解【QTree3】
  7. C#怎么从List集合中随机取出其中一个值
  8. 介绍了ASP。净样板
  9. vector专题
  10. MeteoInfoLab脚本示例:LaTeX写数学公式