Clear, practical technology insights About · Contact

How to Set up Sdl with Visual Studio

Learn how to set up sdl with Visual Studio with clear steps, practical context, and useful troubleshooting guidance.

Author: Micah Soto17 minutes read
Table of Contents

This updated guide examines How to Set up Sdl with Visual Studio and organizes the essential facts, background, and practical takeaways in clear American English.

Method 1

Configuring Visual Studio

  1. How to Set up Sdl with Visual Studio — contextual image 1Highlight step or sub-step.Highlight step or sub-step you expect to do and then do it. See as example picture above.
  2. Download Visual Studio 2019.If you have not done so you can download it from https://www.visualstudio.com/downloads.
  3. How to Set up Sdl with Visual Studio — contextual image 2Check the Desktop development with C++ workload box as you download.If necessary scroll down the page.

Method 2

Downloading SDL

  1. How to Set up Sdl with Visual Studio — contextual image 3Create folder GL .In directory (disk) C:, right click > selectNew>Folder> typeGL< hit Enter.
  2. How to Set up Sdl with Visual Studio — contextual image 4Download the last version of SDL2 .Right click on the following link and select Open Link in New Window https://www.libsdl.org/download-2.0.php. Scroll to the bottom of the page and find Development Libraries . Click the version just below "Windows:" (see the picture above). Today it isSDL2-devel-2.0.10-VC.zip(Visual C++ 32/64-bit).
    1. In downloading window you have the folderSDL2-2.0.10, (or the last version). Click it > right click > select Copy. (Or, alternatively, click it and drag into C:GL).
    2. Navigate to C:GL. Inside GL, right click > select Paste.
    3. Click on nameSDL2-2.0.10, (or the last version), and rename toSDL2. Now in folderGLyou have folderSDL2.

Method 3

Creating Visual Studio Project

  1. How to Set up Sdl with Visual Studio — contextual image 5Create an empty project..
    1. If Visual Studio 2019 is not opened. Open it > ClickCreate a new project>Empty Project>Next.
      1. In "Project name" text field type:Project-0.
      2. Next to "Location" text field click...> Navigate to C: > GL > clickSelect folder. Now "Location" isC:GL.
      3. Check "Place solution and project in the same directory" > clickCreate. Wait till Visual Studio 2019 instance appears.
    2. If Visual Studio 2019 has already been opened. Click File > New > Project… >Create a new project>Empty Project>Next. The rest as above.
  2. How to Set up Sdl with Visual Studio — contextual image 6Add your Source file to the project.
    1. In "Solution Explorer" window right click the "Source Files" folder (the last one).
    2. Click "Add > "New Item…"
    3. In the "Add New Item - Project-0" window, click "C++ File (.cpp)", the first one. "Name:"Source.cppis okay.
    4. The "Location" should be C:GLProject-0. If it's not so, click...to the right of the field and navigate to C: > GL > Project-0. Click "Select folder". Now "Location" isC:GLProject-0.
    5. Click theAddbutton. The file will open in the main text editor but leave the file blank for now.

Method 4

Setting Up SDL2 in Project

  1. How to Set up Sdl with Visual Studio — contextual image 7Configure project's Properties .In "Solution Explorer" right click on the name of your project, that isProject-0, and select "Properties". Leave default settings: Configuration:Active(Debug), and Platform:Active(Win32).
    1. (1) Additional Include Directories.
      1. Open the C/C++ drop-down menu. Click "General" > "Additional Include Directories" > down arrow at the right of the field > "Edit" in the drop-down menu.How to Set up Sdl with Visual Studio — contextual image 8
      2. At the top of the "Additional Include Directories" wizard, click the brown folder icon (the first icon). Click...next to the text box.How to Set up Sdl with Visual Studio — contextual image 9
      3. In the "Select Directory" window, navigate (by double click): C: > GL > SDL2, and click "include" folder. Make sure you have selected the "include" folder. The "Folder" is "include". ClickSelect Folderon the "Select Directory" wizard andOKin the "Additional Include Directories" wizard.
    2. (2) Additional Library DirectoriesOpen the "Linker" drop-down menu, and click "General". Click "Additional Library Directories" entry > down arrow at the end of the field > "Edit" in the drop-down menu.How to Set up Sdl with Visual Studio — contextual image 10
      1. At the top of the "Additional Library Directories" wizard, click the first icon > click...next to the text box.
      2. In the "Select Directory" wizard, navigate C: > GL > SDL2, and double click "lib" folder, followed by clicking "x86" folder. The "Folder" is "x86". ClickSelect folderon "Select Directory" window andOKon "Additional Library Directories" wizard.
    3. (3) Additional DependenciesIn the "Linker" drop-down menu, click "Input" > the "Additional Dependencies" entry > down arrow at the right of the field > "Edit" in the drop-down menu.How to Set up Sdl with Visual Studio — contextual image 11
      1. Copyopengl32.lib; SDL2.lib;SDL2main.liband paste in top-most text box in "Additional Dependencies" wizard > clickOKin the "Additional Dependencies" wizard.
    4. (4) SubSystem. In the "Linker" drop-down menu, click "System" > "SubSystem" > down arrow > select "Windows (/SUBSYSTEM:WINDOWS)" from the dropdown menu. ClickApply>OKon the "SDLproject Property Pages" wizard.How to Set up Sdl with Visual Studio — contextual image 12
  2. Copy "SDL2.dll" file and paste into project-folder.In "File Explorer" navigate C: > GL > SDL2 > lib > x86. In "x86" folder click "SDL2.dll" file > right-click > "Copy".
    1. Navigate C: > GL > Project-0. Right-click on empty area in "SDLproject" folder, and select "Paste".
    2. The "SDL2.dll" file is now in project-folder "Project-0" along with "Source.cpp" and other 4 files created by Visual Studio.How to Set up Sdl with Visual Studio — contextual image 13

Method 5

Testing your Project

  1. Test your project.Copy following code and paste in Source.cpp code area. HitCtrl+F5. If the project builds and a white window with title "An SDL2 window" appears, then the project was set up correctly. You are now ready to program with SDL.
#include"SDL.h"intmain(intargc,char*argv[]){SDL_Init(SDL_INIT_VIDEO);SDL_Window*window=SDL_CreateWindow("An SDL2 window",// window's title10,25,// coordinates on the screen, in pixels, of the window's upper left corner640,480,// window's length and height in pixelsSDL_WINDOW_OPENGL);SDL_Delay(3000);// window lasts 3 secondsSDL_DestroyWindow(window);SDL_Quit();return0;}

Method 6

Correcting errors if any

  1. In "Error List" if you see error
    1. cannot open file SDL.h, go to Part 4, step 1,Configure project's Properties , sub-stepConfigure "Additional Include Directories"and follow instructions.
    2. cannot open file SDL2.lib or SDL2main.lib, go to Part 4, step 1, sub-stepConfigure "Additional Library Directories"and follow instructions. Also to sub-stepConfigure "Additional Dependencies".
    3. "entry point must be defined" go to Part 4, step 1, sub-stepConfigure "System"and follow instructions.
  2. In thrown window with X in red circle.If it is said, file SDL2.dll is missing , go to part 4, step 2,Copy "SDL2.dll" file and paste into project-folderand follow instructions.
  3. For other errors.If you cannot correct them, close Visual Studio > delete project folder Project-0 which lives in C:GL > open Visual Studio > repeat set up from Part (Method) 3. Good job.

Method 7

Creating Project with SDL Template

  1. Create template.Go to Visual Studio and,while "Project-0" is open, click "Project" > "Export Template...". On "Export template Wizard" check "Project Template", if it's not checked. ClickNext >.
    1. On "'Select Template Options'", for "Template name:" typeSDL. ClickFinish. Template has been created.How to Set up Sdl with Visual Studio — contextual image 14
  2. Create project
    1. Click File > New > Project... .
      1. InCreate a new projectwizard scroll down the list of templates and select SDL > clickNext.
      2. InConfigure your new projectwizard, in "Project name" text field type Project-1 . Location should be C:GL. Be sure Place solution and project in the same directory is checked. ClickCreate.
    2. On Solution Explorer , double click Source Files > double click Source.cpp .
      1. If its code appears, it's okay. If does not, right click on Source.cpp that is below Source Files > click Exclude From Project , and create new Source.cpp file.
      2. If a Wizard appears saying: File 'C:GLProject-1Source.cpp' already exists in the project , go to this path and delete the file Source.cpp . ClickOKon the Wizard and then clickAddon the Add New Item - Project-1 window. Now on Solution Explore , below Source Files , you have the new Source.cpp file.
    3. Navigate C: > GL > Project-0 > click file "SDL2.dll" > right click > click "Copy".
    4. Navigate C: > GL > Project-1 > click on empty area > right click > click "Paste".
    5. Now a copy of the file "SDL2.dll" is in folder "Project-1" among "Source.cpp" and other 4 files.
    6. In "Solution Explorer" double click Source Files > Source.cpp . Delete code and paste a new one. HitCtrl+F5.
  3. How to Set up Sdl with Visual Studio — contextual image 15Use your template.Creating a project with an SDL Template is just like creating an ordinary C++ project, but with one more step:
    1. The file "SDL2.dll" should be copied from a previous SDL project-folder and pasted into new project-folder.

Method 8

Create project to target x64 platform

  1. Create empty project as above with name Project-64 and add Source.cpp file.
  2. Project-64's Property Pages main settings.Go to "Solution Explorer" > right click on the name of your project that is Project-64 > select "Properties". In Platform: entry, choose x64 > ClickConfiguration manager...
    1. In Active solution platform: select x64
    2. In Platform entry, x64 is automatically selected.
    3. ClickClose
    4. Tip: Even when in Property Pages wizard, in Platform: entry, x64 is set, clickConfiguration manager..., and in Active solution platform: select x64.
  3. Additional Include Directories.As above, see Method 4, step 1, sub-step (1).
  4. Additional Library Directories.Open the "Linker" drop-down menu, and click "General". Click "Additional Library Directories" entry > down arrow at the end of the field > "Edit" in the drop-down menu.
    1. At the top of the "Additional Library Directories" wizard, click the first icon > click...next to the text box.
    2. In the "Select Directory" wizard, navigate C: > GL > SDL2, and double click "lib" folder, followed by clicking "x64" folder. The "Folder" is "x64". ClickSelect folderon "Select Directory" window andOKon "Additional Library Directories" wizard.
  5. Additional Dependencies.As above, see Method 4, step 1, sub-step (3).
  6. Subsystem.As above, see Method 4, step 1, sub-step (4).
  7. Copy "SDL2.dll" file and paste into Project-64 .In Windows's "File Explorer" navigate to
    1. C: > GL > SDL2 > lib > x64. In "x64" folder click "SDL2.dll" file > right-click > "Copy".
    2. C: > GL > Project-2. Right-click on empty area in "Project-64" folder, and select "Paste".
  8. Test your project and correct errors if any.As with targeting platform x86. See Methods 5 and 6. Good job.
    1. Tip: Even if in Property Pages main settings it is Platform: x64, clickConfiguration manager...and in Active solution platform: select x64.
  9. Create template.As above method 7.
    1. TIP: In every project you create with it, select x64 (next to Debug) in Visual Studio's GUI.

Method 9

Compiling Source Code with CMake and Visual Studio

  1. How to Set up Sdl with Visual Studio — contextual image 16Highlight what you expect to do.For example see picture above.
  2. Create folder GL.In Windows File Explorer, in directory C:, right click on empty area > select New > Folder > type:GL> hitEnter.
  3. How to Set up Sdl with Visual Studio — contextual image 17Download CMake.Right-click on following address and select Open Link in New Window https://cmake.org/download/. Scroll down the page (see image above). Under "Latest Release (today is 3.16.2)" on the second "Platform" list, find "Windows win64-x64. ZIP" and click the beside entry (today iscmake-3.16.2-win64-x64.zip> in opening wizard select Save file .
    1. Copy and unzip the zip folder.
      1. In downloading window, click folder > right click > in drop-down menu select Copy .
      2. Navigate to directory C: > GL > right click > select Paste .
      3. When copying and unzipping (extracting files) is finished, double click unzip foldercmake-3.16.2-win64-x64(or latest version) > bin > inside you should see CMake's logo next to file name cmake-gui > double click this file. If wizard "Windows protect your PC" appears, click More information > Run anyway. Now on your screen you haveCMakeGUI.
      4. Each time you need CMake, navigate to C: > GL > cmake-3.16.2-win64-x64 (or latest version) > bin > double click file cmake-gui (the one with CMake's logo).
  4. Download source code.Right-click on following address and select Open Link in New Window http://libsdl.org/download-2.0.php. UnderSource Codeselect the first option, today isSDL2-2.0.10.zip.
    1. Copy and unzip folder.
      1. In downloading window click zip folderSDL2-2.0.10.zip(or latest version) > right click > select Copy .
      2. Navigate to C: > GL > right click > select Paste .
      3. Now in directory C:GL, you have unzip folderSDL2-2.0.10. Click twice on its name > delete name > type: SDL > hitEnter.
    2. Add the source code. In the CMake GUI first text field, copyC:/GL/SDLand paste.
    3. Add where to build the binaries. In the second text field, copyC:/GL/SDL/buildand paste.
    4. Configure and generate. In CMake GUI, clickConfigure> in wizard Create Directory clickYes> clickFinish.
    5. When, in CMake GUI, you read: "Configuring done", clickGenerate. You should read: "Generating done".
  5. Build your solution.
    1. Navigate to C: > GL > SDL > build. Double click "SDL2.sln", or "SDL2", or "ALL_BUILD.vcxproj". An instance of Visual Studio appears. In the main menu, click "Build" > "Build Solution".
    2. Wait till you read the last line in "Output" window: ========== Build: 5 succeeded, 0 failed, 0 up-to-date, 2 skipped" ==========
      1. TIP: Number of "succeeded" changes in SDL2 versions. Today (28-1-2020) is 5.
  6. Create an empty project.Click 'File > New > Project… >Create a new project>Empty project>Next.
    1. In Project name text box type: pb-0 .
    2. Next to Location text box, click....
    3. Navigate to C: > GL > Click Select a folder . The Location is C:GL.
    4. Check box Place solution and project in the same directory .
    5. ClickCreate.
  7. Add your source file to the Project.In Solution Explorer wizard, right click the Source Files folder (the last one) > click Add > New Item…
    1. In the Add New Item - pb-0 window, click C++ File (.cpp) (the first one) from the middle of the window. In the Name text box, type Main.cpp .
    2. The Location is C:GLpb-0.
    3. Click theAddbutton. The file will open in the main text editor but leave it blank for now.
  8. Configure project's Properties .In Solution Explorer wizard, right click Project's name that is pb-0 > select Properties .
    1. (1) pb-0 Property Pages main menu.In Platform entry select x64 > clickConfiguration Manager....
      1. In Active solution platform: select x64 .
      2. In Platform entry, x64 is automatically selected.
      3. ClickClose.
    2. (2) Additional Include Directories . Click C/C++ > General > In beside menu select the first one, Additional Include Directories > click the down arrow at the end of the field > click Edit... > first icon > three dots...
      1. Navigate to C: > GL > SDL > include > click include > clickSelect a folder> clickOK.
    3. (3) Additional Library Directories . Double click Linker > click General > Additional Library Directories > click the down arrow at the end of the field > click Edit... > first icon > three dots....
      1. Navigate to C: > GL > SDL > build > Debug > clickSelect a folder> clickOK.
    4. (4) Additional Dependencies . In Linker drop-down menu select Input > in beside menu select the first one, Additional Dependencies > click the down arrow at the end of the field > Edit... > copyopengl32.lib; SDL2maind.lib; SDL2d.liband paste in Additional Dependencies wizard's upper-most text box > clickOK.
    5. (5) Set System to SubSystem CONSOLE.In Linker drop-down menu select System > in beside menu select the first one, SubSystem > click the down arrow at the end of the field > select Console (/SUBSYSTEM:CONSOLE) . ClickApplyandOK.
  9. Copy SDL2d.dll file and paste in pb-0 project.Navigate to C: > GL > SDL > build > Debug, and copy (by right click > Copy) file SDL2d.dll .
    1. Navigate to C: > GL > pb-0, and paste. Now in project folder pb-0 you have DLL file SDL2d.dll among Source.cpp and other 4 files created by Visual Studio.
  10. Test your project and correct errors if any.Follow Methods 5 and 6.
  11. Create template.Follow Method 7. Every time you create project with this template, select x64 in Visual Studio GUI's main menu. Good job.

Method 10

Choosing Set Up

  1. In this tutorial you learn 3 was to set up SDL in Project with Visual Studio.
    1. Set up binaries x86 (32 bits).It's the easiest. You should start learning set up from here.
    2. Set up binaries x64 (64 bits).It targets x64 platform. Choose it only when you have specific reason for doing so.
    3. Compile SDL source, and set up in project.Targets x64 too. The most difficult. The best though.

Frequently Asked Questions

What is How to Set up Sdl with Visual Studio about?

It provides a structured overview of click, explains the main context, and highlights practical takeaways for readers.

Why does this topic matter?

Understanding the main concepts helps readers evaluate the issue, avoid common mistakes, and make better-informed decisions.

How should readers use this information?

Use the guidance as a practical starting point, confirm details that may have changed, and follow current product, safety, or security recommendations.

Was this article helpful?

Your feedback helps us improve.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.