Setting up SDL 2 on Visual Studio 2010 Ultimate

Posted justbeginning

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Setting up SDL 2 on Visual Studio 2010 Ultimate相关的知识,希望对你有一定的参考价值。

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

You‘ll want to download the visual c++ development libraries.

技术分享图片

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 Studio. For these tutorials I‘m putting them in a directory I created called C:vs_dev_lib

2)Start up Visual Studio and create a new empty project.

技术分享图片

 

 

3)Go to project properties.

技术分享图片

 

 

4)Now we have to tell Visual C++ to search for header files in the SDL 2 include folder we just extracted. Under Configuration Properties in the VC++ Directories menu, select the Include Directories field, click the tiny down arrow button, and click edit.

技术分享图片

 

 

5)Click the folder icon, and then click the button that pops up.

技术分享图片

 

 

6)Now go find the SDL2 folders you extracted, and select the include folder and click OK.

技术分享图片

 

Now Visual Studio knows where to find the header files. If you get an error that the compiler can‘t find SDL.h, it means you messed up this step.

7)Next we going to tell Visual C++ to search for library files in the SDL 2 library folder we just extracted. Select the Library Directories field, click the tiny down arrow button, and click edit.

技术分享图片

 

 

8)Click the folder icon, and then click the button that pops up.

技术分享图片

 

 

9)Now go find the lib folder you extracted, and select the lib folder where you find two folders. There‘s one for 32bit x86 architecture and for 64bit x64 architecture.

技术分享图片

 

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. This means you need to select the x86 folder and click ok. Now Visual Studio knows where to find the library files. If you get an error how the linker can‘t find SDL2.lib, it means you missed this step.

10)In order to compile SDL code, we have to tell the Visual C++ to link against the libraries. Go under Linker in the Input menu, edit the additional dependencies.

技术分享图片

 

 

11)Now paste

SDL2.lib;
SDL2main.lib;
into the Additional dependencies field and click OK.
技术分享图片
Now Visual Studio knows to link against SDL 2. If you get a bunch of undefined reference error after compiling, it means you messed up this step.
 
12)Under Linker in the System menu, set the subsystem.
技术分享图片
 
You can set it to Windows if you don‘t want console output, and Console if you do want console output. For this tutorial set, errors will be printed on the console, so I recommend leaving it as a console application as you are still learning and prototyping. If you get an error about an entry point not being defined or unresolved external symbol _main it means you skipped this step.
 
13)When our SDL 2 application runs, the operating system needs to be able to find the dll file.

Go find the SDL 2 lib folder you extracted and copy SDL2.dll and put it either your project‘s working directory (where the vcxproj file is at), or inside of the system directory. C:WINDOWSSYSTEM32 is the 32bit windows system directory and C:WindowsSysWOW64 is the 64bit system directory of 32bit applications. For these tutorials, I‘m assuming we‘re making 32bit applications.
 
14)Now go download the source for lesson 01. Add the source file 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‘s time to go onto part 2 of the tutorial.
 

 

 








以上是关于Setting up SDL 2 on Visual Studio 2010 Ultimate的主要内容,如果未能解决你的问题,请参考以下文章

setting up kernel debugging on a vmworkstation virtual machine

Docker For Windows | Setting Up Docker On Windows

怎么在linux 系统下,禁用和启用网卡(up/down), setting IP

4.5 Routing -- Setting Up A Controller

SVNKit学习——Setting Up A Subversion Repository 创建仓库

Oracle ODI 12c之Setting Up Simple CDC