-
Notifications
You must be signed in to change notification settings - Fork 86
Home
You can find the source code for C++ for Beginners here.
Here's a link on how to set up SDL with Visual Studio 2017.
General Windows Notes
On Windows, you may need to add #define SDL_MAIN_HANDLED
before including SDL.h, to avoid getting an "undefined reference to WinMain@162" error.
Also, see the note later about dynamic link libraries (.dll files on Windows).
Windows and Eclipse
If you're using Windows with Eclipse and you get a message saying SDLBasic.exe does not exist, first check (in explorer or in Eclipse after right-clicking the project and going to "refresh") that SDLBasic.exe actually does exist. If it does, try this:
- Right click on the project
- Go to "properties"
- Expand C/C++ build
- Click on settings
- Click on Binary Parsers tab
- Select PE Windows Parser
- Click on Move Up until it is at the top
Here are some further instructions that might help you if you're using Windows with Eclipse.
The following was kindly passed on to us by someone who felt they were likely to prove useful.
For Linux, begin by downloading SDL through the teriminal using either
sudo apt-get install libsdl2-2.0
or
sudo yum install SDL2
if you have issues at this step, go to https://wiki.libsdl.org/Installation#Linux.2FUnix, they give step by step instructions on downloading SDL.
Next, use command line to find it (whereis SDL2
and whereis libSDL2
), it generally appears in /usr/include and /usr/lib (include has the includes and lib has the libraries) and follow John to work them with Eclipse.
The final project in this course uses SDL, a popular cross-platform graphics library.
C+++ libraries are often not easy to get working (C++ is a challenging language!). Configuring SDL for your platform might take some googling and experimentation.
The exact method for getting your program working with SDL seems to vary a fair bit, depending on your OS, the version of your OS, and probably your compiler.
Since SDL is a popular graphics library, any error message you encounter in setting it up can be googled (you might want to add in your OS and version, e.g. "Windows 10" to your search keywords) and you'll find suggested solutions for your problem.
On the Mac, you might find this YouTube video helpful. When I created the course, I could not get an approach using the Mac SDL "framework" to work and formed the impression that it was buggy at the time. But as you can see in this video from August 2017, whether it worked before or not (maybe I was just doing something wrong), it works now.
Since OSX is a UNIX/Linux-like system, you should also be able to take the approach I used myself for the course, and just make sure your app can find the SDL headers and links with the correct library.
On all operating systems, unless you succeed in statically linking the SDL API (in other words, building all the SDL code into your executable directly -- now possible, but not recommended by the creators of SDL), you'll need to make sure the dynamic library is somewhere your app can find it. Dynamic libraries contain code that your program finds when it runs. They typically have the extension .dll on Windows, .so on Linux, and .dylib or .so on the Mac. Just having them in the same directory as your app, or in the project folder in Eclipse, may well do the trick.