from:http://lazyfoo.net/tutorials/SDL/01_hello_SDL/index.php

Last Updated 6/11/19

So you learned the basics of C++, but you're sick of making little text based programs. In order to use things like graphics, sound, keyboards, joysticks, etc you need an API (Application Programmer's Interface) that takes all those hardware features and turns it into something C++ can interact with.

That's what SDL does. It takes the Windows/Linux/Mac/Android/iOS/etc tools and wraps them in a way that you can code something in SDL and compile it to what ever platform it supports. In order to use it, you need to install it.

SDL as a dynamically linked library. A dynamically linked library has 3 parts:

    • The header files (Library.h)
    • The library files (Library.lib for windows or libLibrary.a for *nix)
    • The binary files (Library.dll for windows or Library.so for *nix)

Your compiler needs to be able to find the header files when compiling so it knows what SDL_Init() and the other SDL functions and structures are. You can either configure your compiler to search in an additional directory where the SDL header files are located, or put the header files in with the rest of header files that your compiler comes with. If the compiler complains that it can't find SDL.h, it means the header files aren't in a place that the compiler looks for header files.

After your compiler compiles all your source files it has to link them together. In order for the program to link properly, it needs to know the addresses of all your functions including the ones for SDL. For a dynamically linked library, these addresses are in the library file. The library file has the Import Address Table so your program can import the functions at runtime. Like with header files, You can either configure your compiler to search in an additional directory where the SDL library files are located, or put the library files in with the rest of library files that your compiler comes with. You also have to tell the linker to link against the library file in the linker. If the linker complains that it can't find -lSDL or SDL2.lib, it means the library files aren't in a place that the linker looks for library files. If the linker complains about an undefined reference, it probably means it was never told to link the library.

After your program is compiled and linked, you need to be able to link against the library when you run it. In order to run a dynamically linked application, you need to be able to import the library binaries at runtime. Your operating system needs to be able to find the library binary when you run your program. You can either put the library binaries in the same directory as your executable, or a directory that your operating system keeps library binary files.

After you set up SDL, we'll cover how to create an SDL 2 window.

Select Your Operating System
Windows
Linux
Mac OS X

【转】Hello SDL的更多相关文章

  1. Visual studio 通用开发环境配置:SDL,FFMPEG为例

    引言 每一个C++库的使用都是从开发环境的配置开始的,其实每个库的配置过程都是大同小异,总结下来有下面几个步骤: 下载库文件,这里假定是已经预先编译完成的. 配置库文件的包含目录(include)和库 ...

  2. SDL 1.2.15 issue

    SDL 1.2.15中,对于X11的函数,默认采用动态加载的方式 但相应的X11函数名在SDL中并没有重新命名(SDL2中都添加了前缀X11_) 这样在SDL与其他库混合静态编译链接时,X11的函数就 ...

  3. SDL简介(网络汇总)

    摄像头视频播放采用sdl,下面简单介绍下.不保证正确及网址永远有效.后面文章采用tao框架http://sourceforge.net/projects/taoframework/      SDL. ...

  4. SDL第一个程序:加载一张图片

    直接看代码吧 using System; using System.Collections.Generic; using System.ComponentModel; using System.Dat ...

  5. SDL文字和图形

    SDL本身没有显示文字功能,它需要用扩展库SDL_ttf来显示文字.ttf是True Type Font的缩写,ttf是Windows下的缺省字体,它有美观,放大缩小不变形的优点,因此广泛应用很多场合 ...

  6. SDL鼠标事件

    鼠标事件有这么多种,手柄的可以忽视,Sdl.SDL_KEYDOWN,Sdl.SDL_KEYUP,Sdl.SDL_MOUSEMOTION,Sdl.SDL_MOUSEBUTTONDOWN,Sdl.SDL_ ...

  7. SDL绑定播放窗口 及 视频窗口缩放

    绑定播放窗口 必须在Sdl.SDL_Init之前执行 Sdl.SDL_putenv 同时SDL_SetVideoMode里播放窗口长宽不能大于绑定窗口的长宽 int i = Sdl.SDL_puten ...

  8. SDL 显示解码后的yuv12数据

    在上篇h264解码为yuv12后http://jhlong12345.blog.163.com/blog/static/1230631292015725115058709/ ,需要显示出来,使用sdl ...

  9. SDL 截图、录像、录像播放

    截图 使用sdl很简单,视频显示窗口大小,不是视频分辨率大小 int i = Sdl.SDL_SaveBMP(surfacePtr, path); if(i != 0) { MessageBox.Sh ...

  10. 简单播放器(增加sdl事件控制)

    #include <libavcodec/avcodec.h> #include <libavformat/avformat.h> #include <libswscal ...

随机推荐

  1. 从watevrCTF-2019:Pickle Store中学习python之pickle序列化漏洞

    从watevrCTF-2019:Pickle Store中学习python之pickle序列化漏洞 pickle提供了一个简单的持久化功能.可以将对象以文件的形式存放在磁盘上. 其本质是Picklin ...

  2. 项目升级springboot2.0注意事项

    一.pring boot 2.0以后, springboot jpa findById 返回类型变化@NoRepositoryBeanpublic interface CrudRepository&l ...

  3. vue下history模式刷新后404错误解决

    官方说明文档: https://router.vuejs.org/zh/g... 一. 实测 Linux 系统 Apache 配置: 更改站点配置文件即可,我这里在 Directory 标签后面添加了 ...

  4. 2020.09 问题总结(Oracle-->MySQL、Maven、JSP-->Thymeleaf、Druid)

    2020.09 问题总结(Oracle-->MySQL.Maven.JSP-->Thymeleaf.Druid) 数据库建表 Oracle 转 MySQL 问题 Oracle MySQL ...

  5. const放在函数前后的区别

    转载:const放在函数前后的区别 一.const修饰指针 int b = 500; 1.const int * a = & b; 2.int const * a = & b; 3.i ...

  6. Zyan Drench,支持Wifi的Android游戏

    下载source - 298 KB 介绍 "雨淋"是一款最初使用Adobe Flash开发的单人游戏(你可以试试谷歌一下"世界上最简单的Flash游戏").它相 ...

  7. 【5】进大厂必须掌握的面试题-Java面试-spring

    spring面试问题 Q1.什么是spring? Spring本质上是一个轻量级的集成框架,可用于用Java开发企业应用程序. Q2.命名Spring框架的不同模块. 一些重要的Spring Fram ...

  8. Oracle体系结构概述与SQL解析剖析

    Oracle服务器 是一个数据库管理系统,它提供了一种全面.开放.集成的方法来管理信息. Oracle服务器由Oracle数据库和Oracle实例组成. oracle数据库软件和Oracle数据库软件 ...

  9. 多测师讲解selenium_输入性弹框定位_高级讲师肖sir

    #输入性弹框from selenium import webdriverfrom time import sleepdrvier=webdriver.Chrome()url='file:///F:\d ...

  10. 在Jenkins容器中安装docker-compose

    首先使用Docker容器安装Jenkins 链接参考 安装成功后使用管理员权限进入到Jenkins容器 docker exec -it -u root jenkins bash 下载docker-co ...