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. 阿里云恶意软件检测比赛-第三周-TextCNN

    LSTM初试遇到障碍,使用较熟悉的TextCNN. 1.基础知识: Embedding:将词的十进制表示做向量化 起到降维增维的作用 嵌入维度数量(New Embedding维度)的一般经验法则: e ...

  2. 转载:python的format格式化输出

    https://www.cnblogs.com/chunlaipiupiupiu/p/7978669.html python中format函数   ---恢复内容开始--- python中format ...

  3. MySQL中concat()、concat_ws()、group_concat()函数的使用技巧与心得总结

    Author:极客小俊 一个专注于web技术的80后 我不用拼过聪明人,我只需要拼过那些懒人 我就一定会超越大部分人! CSDN@极客小俊,原创文章, B站技术分享 B站视频 : Bilibili.c ...

  4. Win10系统下的MySQL5.7.24版本(解压版)详细安装教程

    进入MySQL官网下载压缩包 MySQL官网:https://www.mysql.com/ 将页面拉到最底,点击MySQL Community Server 跳转到下载页面,默认选择是最新版MySQL ...

  5. 032 01 Android 零基础入门 01 Java基础语法 03 Java运算符 12 运算符和if-else条件语句的综合案例——闰年问题

    032 01 Android 零基础入门 01 Java基础语法 03 Java运算符 12 运算符和if-else条件语句的综合案例--闰年问题 本文知识点:运算符和if-else条件语句的综合案例 ...

  6. Python数据结构与算法之图的最短路径(Dijkstra算法)完整实例

    本文实例讲述了Python数据结构与算法之图的最短路径(Dijkstra算法).分享给大家供大家参考,具体如下: # coding:utf-8 # Dijkstra算法--通过边实现松弛 # 指定一个 ...

  7. 浙大《数据结构》学习&练习(一)算法初步

    1.数据结构是数据在计算机中的组织方式,类比图书在图书馆中的存储,应该如何分类,如何在书架上存取. 2.抽象数据结构是对一类的数据的一种组织方式的通用(抽象)描述,包括类型的名称,数据对象集和操作集. ...

  8. 《穷查理年鉴》朋友 & 爱人 & 相处 (关于他人)

    朋友 017.物以类聚,人以群分. 018.没有什么比拥有谨慎而忠诚的朋友更好的人. 019.人有三个忠实的朋友:老妻.老狗和现钞. 020.旅行者须有猪鼻.鹿腿与驴背. 028.聪明的人才触及他人的 ...

  9. 【Flutter Widgets大全】电子书开源

    [Flutter Widgets大全]是老孟耗费大量精力整理的,总共有330多个组件的详细用法,开源到Github上,希望可以帮助到大家,开源不易,点个赞可不可以. [Flutter Widgets ...

  10. 跟随Javac代码来解答字节码的疑惑

    前言 本文是跟随掘金小册张师傅的<JVM字节码从入门到精通>练习而写的. 问题 问题一: 有如下代码: 1 package com.sun.tools.javac; 2 3 /** 4 * ...