【转】Setting up SDL 2 on Visual Studio 2019 Community
FROM: http://lazyfoo.net/tutorials/SDL/01_hello_SDL/windows/msvc2019/index.php
Setting up SDL 2 on Visual Studio 2019 Community
Last Updated 7/20/20
You'll want to download the Visual C++ development libraries.
![](https://img2020.cnblogs.com/blog/394545/202008/394545-20200817155426755-1713493729.png)
Open the zip archive and there should be a folder called SDL2-2.something.something. Copy the contents of the folder and put it anywhere you'd like. I recommend putting it in a folder that you dedicate to holding all your development libraries for Visual C++. For these tutorials I'm putting them in a directory I created called C:\vclib
2)Start up Visual Studio and create a new empty C++ project.
![](https://img2020.cnblogs.com/blog/394545/202008/394545-20200817155446511-404452797.png)
Give your project/solution whatever name you'd like and place it where ever you'd like.
3)Go download the source for lesson 01 and extract the source file. Right click on the source files folder in your solution, and then add the source file you downloaded.
![](https://img2020.cnblogs.com/blog/394545/202008/394545-20200817155505292-844039897.png)
4)Now, if your default build setting is Debug x86, you may need to change it:
![](https://img2020.cnblogs.com/blog/394545/202008/394545-20200817155519226-310782167.png)
For the rest of this tutorial, we will be assuming you are building for Debug x64 so make sure your configuation is set to Debug x64. Because libraries are different per configuation, you will need to add SDL to every configuation you plan on using. So if you want to build for Release x64 or Debug x86, you will need to add SDL2 to each configuation.
5)Build your solution and you should get the following error:
Cannot open include file: 'SDL.h': No such file or directory
This means Visual C++ cannot find the SDL header files and you need to add the SDL include folder to the Visual C++ include directories.
Go to project properties:
![](https://img2020.cnblogs.com/blog/394545/202008/394545-20200817155531153-2068688048.png)
Go to Configuration Properties -> VC++ Directories -> Include Directories -> Edit.
![](https://img2020.cnblogs.com/blog/394545/202008/394545-20200817155547525-1656816059.png)
And then add the include directory from the SDL development folder we extracted.
![](https://img2020.cnblogs.com/blog/394545/202008/394545-20200817155610079-2052746251.png)
6)Try to build your solution again and you should get a bunch of errors including:
unresolved external symbol SDL_GetError referenced in function SDL_main
The header file tells the compiler what the SDL functions are, not where to find them. The library file tells the compiler where they are and we need to tell it to use the SDL library file. Go to Configuration Properties -> Linker -> Additional Dependencies -> Edit.
![](https://img2020.cnblogs.com/blog/394545/202008/394545-20200817155625469-1774244401.png)
Now add
SDL2.lib; SDL2main.lib;
![](https://img2020.cnblogs.com/blog/394545/202008/394545-20200817155635504-1568905065.png)
7)Try to build your solution again and you should get a new error:
cannot open file 'SDL2.lib'
While we did tell Visual C++ to use the SDL library files, we didn't tell it where to find it. Add the library directory like you did the include directory
![](https://img2020.cnblogs.com/blog/394545/202008/394545-20200817155649136-1407239642.png)
Make sure to add the library that matches your build configuation. If your building for x64, make sure to use the x64 library.
![](https://img2020.cnblogs.com/blog/394545/202008/394545-20200817155704839-352033195.png)
8)Build and your application should build, but try to run it and you'll get this error:
The code execution cannot proceed because SDL2.dll was not found.
This is because your application needs SDL2.dll to run but can't find it. Windows uses environment variables to define where to look for dll files. To edit the PATH environment variable, go into Windows Settings and search for edit the system environment variables:
![](https://img2020.cnblogs.com/blog/394545/202008/394545-20200817155719573-2043853859.png)
Click environment variables and under System Variables select Path and click Edit
![](https://img2020.cnblogs.com/blog/394545/202008/394545-20200817155742804-1563068594.png)
Then click new, then browse to add the lib directory for your build configuation:
![](https://img2020.cnblogs.com/blog/394545/202008/394545-20200817155801738-869920784.png)
Restart Visual Studio so Visual C++ can get the updated path variable, start your program and it should run.
Now that you have SDL 2 compiling, it's time to go onto part 2 of the tutorial.
【转】Setting up SDL 2 on Visual Studio 2019 Community的更多相关文章
- 【转】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 ...
- 【转】Setting up SDL Extension Libraries on Visual Studio 2019 Community
FROM:http://lazyfoo.net/tutorials/SDL/06_extension_libraries_and_loading_other_image_formats/windows ...
- 解决VS命令提示符 “Setting environment for using Microsoft Visual Studio. 此时不应有“系列错误
一.起因 近期在玩Boost库.当然首先是要进行Boost库的安装和配置.于是浅墨Google了一下boost库的安装配置攻略.下载了最新版1.55的boost库.就愉悦地開始进行配置了. 当进行到第 ...
- Visual Studio 2019 发布活动 - 2019 年 4 月 2 日
Visual Studio 2019 发布活动 2019 年 4 月 2 日,星期二 | 上午 9:00 (PT) 围观: https://visualstudio.microsoft.com/zh- ...
- Visual Studio 2019 正式发布,重磅更新,支持live share
如约而至,微软已于今天推出 Visual Studio 2019 正式版,一同发布的还有 Visual Studio 2019 for Mac. Visual Studio 2019 下载地址:htt ...
- “宇宙最强” IDE,Visual Studio 2019 正式发布
转载请注明出处:葡萄城官网,葡萄城为开发者提供专业的开发工具.解决方案和服务,赋能开发者. 本文由葡萄城翻译并发布 今天凌晨Visual Studio 2019已经正式发布,现在已经可以下载了.使用V ...
- Visual Studio 2019 使用 Live Share
一.前言 Visual Studio 2019 在今天发布(北京时间)了,这次带来了一个比较有趣的 Live Share 功能,使用它可以进行更好的协作开发.主要功能: 更多资料可看官方介绍: Vis ...
- Visual Studio 2019 正式版 更新内容
大早上更新了Visual Studio 2019, 试用一下 一.界面改变 1.项目创建界面 首先启动界面改变就不说了,创建项目的界面做了较大改变,感觉在向vs for mac 靠拢 ,而后者感觉像x ...
- Making every developer more productive with Visual Studio 2019
Today, in the Microsoft Connect(); 2018 keynote, Scott Guthrie announced the availability of Visual ...
随机推荐
- 搭建Linux服务器
工欲善其事必先利其器, 虚拟机:百度云链接地址:https://pan.baidu.com/s/1_nWQh3WKF7xLs5-nmbZ8lA (Vmware 12 ) Linux 7:百度云链接 ...
- echarts配置进度池
近日,使用dataV中的配置,完成了进度池图表,但是有有一个缺点,就是官方没有动画方面的配置.如下图: 为了给这个进度池添加动画效果,我反向的在进度池上面铺一层由一格一格与进度池中相同的块状组成的与背 ...
- PHP_加密解密字符串
PHP_加密解密字符串.php <?php //加解密字符串函数,可以加密中文 /* //加密 echo $encode = authcode('爱迪生', 'ENCODE', '3'); // ...
- mysql 空值(null)和空字符('')的区别
日常开发中,一般都会涉及到数据库增删改查,那么不可避免会遇到Mysql中的NULL和空字符. 空字符(")和空值(null)表面上看都是空,其实存在一些差异: 定义: 空值(NULL)的长度 ...
- mysql-10-union
#进阶10:联合查询 /* union联合 将多条查询语句的结果合并成一个结果 语法: 查询1 union 查询2 union 查询3 ... 应用场景:要查询的结果来自于多个表,且多个表没有直接的连 ...
- 083 01 Android 零基础入门 02 Java面向对象 01 Java面向对象基础 02 构造方法介绍 02 构造方法-带参构造方法
083 01 Android 零基础入门 02 Java面向对象 01 Java面向对象基础 02 构造方法介绍 02 构造方法-带参构造方法 本文知识点:构造方法-带参构造方法 说明:因为时间紧张, ...
- Java知识系统回顾整理01基础02面向对象03方法
一.根据实例给出"方法"的定义 在LOL中,一个英雄可以做很多事情,比如超神,超鬼,坑队友 能做什么在类里面就叫做方法 比如队友残血正在逃跑,你过去把路给别人挡住了,导致他被杀掉. ...
- matlab一个figure画多个子图,和多个figure画多个图。
参考:https://blog.csdn.net/xiaotao_1/article/details/79024488 1,一个figure画多个子图: figure(10) % define fig ...
- .NET Standard SDK 样式项目中的目标框架
系列目录 [已更新最新开发文章,点击查看详细] 包表示形式 .NET Standard 引用程序集的主要分发载体是 NuGet 包. 实现会以适用于每个 .NET 实现的各种方式提供. NuG ...
- 小白使用Hystrix
Hystrix是什么东西?百度一下: 没错,hystrix是豪猪的意思,作为SpringCloud微服务系统中保持服务稳定的重要组件,正如它的名字一样,它对整个系统起到了保护的作用. 在许多文章当中把 ...