SDL2/C++ Tutorial. Setting Up SDL & Creating Your First Window Visual Studio 2017

preview_player
Показать описание


This video shows you how to download and set up SDL2 on windows using Visual Studio 2017. I Then continue to show you how to create your first window in C++.

If you have any questions/comments please leave them below and I will do my best to get back to you.
Рекомендации по теме
Комментарии
Автор

For those of you getting "unresolved external symbols" errors with the x64 build: make sure that you're building for x64 and not Win32. In the video, you can see that his properties window shows the platform as "All Platforms". This is usually Active(Win32) by default, which obviously isn't x64 (basically trying to build an x86 project with x64 binaries), so if you follow this tutorial as shown then you'll get the aforementioned linker errors. If you click on the "Configuration Manager" button in the properties window and switch the "Active Solution Platform" and "Platform" to x64, then you should be good to go. This is also the reason why switching to the x86 libs and pasting in the x86 dll works too because you're matching up the specified platform (Win32 by default) with the right libs and binaries. Hope this helps!

BugBiteSquared
Автор

Followed the tutorial and this code still works on Visual Studio 2022 with SDL2 2.26.5. I had my configuration and platform set to all. My active solution platform was set to x64.

influentialdiscovery
Автор

To solve "unresolved external symbols"
1) Right-click the "FirstSDLWindow" directory in the solutions explorer, to get to properties.
2) At the top it has Configuration and Platform, set this to All Configurations and All Platforms
3) Make sure your project is set to x64, this option is to the left of the "Local Windows Debugger" button

Hopefully that fixes it, I deleted my initial project and rebuilt it with these options and it worked.

toniasanzo
Автор

this video just solved a whole bunch of problems that i have been struggling with. this is the first guide i have found of any kind that explains the COMPLETE step by step process for including libraries into a project. THANK YOU!!!

i had managed to piece together all of the rest of it, but none of the other instructions i found told me that i had to copy the .dll files into the project folder.

blinkin
Автор

Know this is old, but I've been looking for a summer project and this is a great start for it!

sandertan
Автор

seems to be harder to find a visual studio code setup for SDL. Does one exist?

synthoelectro
Автор

Thanks for this tutorial so far! For anyone viewing this tutorial in Visual Studio 2019

BlackFox is right about selecting x64. What worked for me was to select the x64 options from the beginning before doing any of the linking stuff in the video.

Right click your project name in the solution explorer and click Properties.
In the top right click Configuration Manager...
Active Solution Platform and Platform should be set to x64 (left mine on debug configuration)
Click Apply and OK
At the top of the main Visual Studio window, make sure the option next to build is x64

Should work then. Good luck!

poupdujour
Автор

Thanks to you, I can finally make graphics programs in C++

powerhouseofthecell
Автор

I'm watching this 6 years after being uploaded and i must say its still effective

ATLAEhEaM
Автор

I was trying to do anything using SDL lib but all the tutorials from other videos ended up giving an error, you were the first one that didn't go wrong thank you dude :-D.

I was about to give up on trying to use SDL

styles
Автор

To anyone who has similar issues to what I had: if you did everything in the video and got build errors such as "cannot open source file X", it may be an issue either with where you placed your SDL2 folder or maybe windows settings or permissions that didn't allow Visual Studio to interact with the files it needed. Not too sure what the exact problem was that I faced but I tried everything again in a virtual machine and got no build errors that time.

Some possible fixes to resolve your build errors:
-Reinstalling windows and not touching any windows permission settings or manually enabling ones you might have disabled before
-Moving your SDL2 folder from where you had it to the root of your storage drive (mine was in a folder on my desktop which might have been problematic)
-Reinstalling Visual Studio but not unchecking any of the optinal features (I did this initially so maybe one of the optional features are needed for your project to work)

Hope this helps. Was quite annoyed when my project didn't start up after I followed everything but was able to fix it with a fresh VM.

iceangelx
Автор

Thankyou so much for this, without this I would have never been able to get into SDL2.Thankyou.

likun
Автор

if you are getting unresolved external something on windows, remove "const" from main, eg. int main(int argc, char* argv[]), it helped me

andreykolechko
Автор

The Best Video For Starting to use SDL, and trust me I hace try with a looot of videos befor this and this one is the best, thank you very much !!!!

cristianrubi
Автор

Im still learning coding and my dream is to create a game that will be loved by everyone. Im going to study programmings next year. Its good to learn early how to do things like this.

Vampir_Myc
Автор

Thank you! Finally find a C++ VS game tutorial I can follow without any strange error T_T

wilamlu
Автор

OMG Thank you! I have been struggling with SDL2 and vscode. This was the first helpful tutorial!

BeesUSA
Автор

a tip if yoou have a problem like mine:
i did get a window but it didn't have any color. to fix this, i added SDL_RenderFillRect(renderer, NULL) after SDL_SetRenderDrawColor and it worked. great tut btw 👍

AnshrajGamez
Автор

It worked for me! Thank goodness SDL2 doesn't have a bunch of other dependencies. Thank you for the video!

macewindont
Автор

Well done. You deserve a medal for this mate, it's perfect. No waffle, just the crucial facts. It isn't just a class in how to get an SDL project running easily, it's a class in how to make a tutorial.

The single problem I had was the one mentioned below which was compiling for 32bit generated a host of errors. Luckily I tried changing my platform to x64 and it worked. Confusingly it does say "x86" in your screen.

Well done though, I really enjoyed following that.

vapourmile
visit shbcf.ru