slouken@0: slouken@521: slouken@521: Using SDL with Microsoft Visual C++ slouken@521: slouken@521: slouken@521:

slouken@7229: Using SDL with Microsoft Visual C++ slouken@521:

slouken@521:

slouken@521: by Lion Kimbro and additions by slouken@521: James Turk slouken@521:

slouken@521:

slouken@7229: You can either use the precompiled libraries from the SDL Download web site , or you can build SDL yourself. slouken@521:

slouken@521:

slouken@521: Building SDL slouken@521:

slouken@521:

slouken@7229: Go into the VisualC directory and double-click on the Visual Studio solution for your version of Visual Studio, e.g. SDL_VS2008.sln This should open up the IDE. slouken@521:

slouken@521:

aschiffler@7314: There are different solution files for the various aschiffler@7314: versions of the IDE. Please use the appropiate version slouken@8849: 2008, 2010, 2012 or 2013. aschiffler@7314:

aschiffler@7314:

slouken@521: Build the .dll and .lib files. slouken@521:

slouken@521:

slouken@521: This is done by right clicking on each project in turn (Projects are listed in slouken@521: the Workspace panel in the FileView tab), and selecting "Build". slouken@521:

slouken@521:

slouken@521: You may get a few warnings, but you should not get any errors. You do have to slouken@7229: have at least the DirectX 9 SDK installed, however. The latest slouken@7229: version of DirectX can be downloaded from Microsoft. slouken@521:

slouken@521:

slouken@521: Later, we will refer to the following .lib and .dll files that have just been slouken@521: generated: slouken@521:

slouken@521: slouken@521:

slouken@7229: Search for these using the Windows Find (Windows-F) utility inside the VisualC directory. slouken@521:

slouken@521:

slouken@521: Creating a Project with SDL slouken@521:

slouken@521:

slouken@521: Create a project as a Win32 Application. slouken@521:

slouken@521:

slouken@521: Create a C++ file for your project. slouken@521:

slouken@521:

slouken@521: Set the C runtime to "Multi-threaded DLL" in the menu: Project|Settings|C/C++ slouken@521: tab|Code Generation|Runtime Library . slouken@521:

slouken@521:

slouken@521: Add the SDL include directory to your list of includes in the slouken@521: menu: Project|Settings|C/C++ tab|Preprocessor|Additional include directories slouken@521: . slouken@521:
slouken@521: VC7 Specific: Instead of doing this I find it easier to slouken@521: add the include and library directories to the list that VC7 keeps. Do this by slouken@521: selecting Tools|Options|Projects|VC++ Directories and under the "Show slouken@521: Directories For:" dropbox select "Include Files", and click the "New Directory philipp@7338: Icon" and add the [SDLROOT]\include directory (e.g. If you installed to philipp@7338: c:\SDL\ add c:\SDL\include). Proceed to change the slouken@521: dropbox selection to "Library Files" and add [SDLROOT]\lib. slouken@521:

slouken@521:

slouken@521: The "include directory" I am referring to is the include folder slouken@521: within the main SDL directory (the one that this HTML file located within). slouken@521:

slouken@521:

slouken@521: Now we're going to use the files that we had created earlier in the Build SDL slouken@521: step. slouken@521:

slouken@521:

slouken@521: Copy the following files into your Project directory: slouken@521:

slouken@521: slouken@521:

slouken@521: Add the following files to your project (It is not necessary to copy them to slouken@521: your project directory): slouken@521:

slouken@521: slouken@521:

slouken@521: (To add them to your project, right click on your project, and select "Add slouken@521: files to project") slouken@521:

slouken@521:

Instead of adding the files to your project it is more slouken@521: desireable to add them to the linker options: Project|Properties|Linker|Command slouken@521: Line and type the names of the libraries to link with in the "Additional slouken@521: Options:" box.  Note: This must be done for each build philipp@7338: configuration (e.g. Release,Debug).

slouken@521:

slouken@521: SDL 101, First Day of Class slouken@521:

slouken@521:

slouken@521: Now create the basic body of your project. The body of your program should take philipp@8855: the following form: philipp@8855:


philipp@7338: #include "SDL.h"
slouken@0: 
slouken@0: int main( int argc, char* argv[] )
slouken@0: {
slouken@0:   // Body of the program goes here.
slouken@0:   return 0;
slouken@0: }
philipp@8855: 			
slouken@521:

slouken@521:

slouken@521: That's it! slouken@521:

slouken@521:

slouken@521: I hope that this document has helped you get through the most difficult part of slouken@521: using the SDL: installing it. Suggestions for improvements to this document slouken@521: should be sent to the writers of this document. slouken@521:

slouken@521:

slouken@521: Thanks to Paulus Esterhazy (pesterhazy@gmx.net), for the work on VC++ port. slouken@521:

slouken@521:

slouken@521: This document was originally called "VisualC.txt", and was written by slouken@521: Sam Lantinga. slouken@521:

slouken@521:

slouken@521: Later, it was converted to HTML and expanded into the document that you see slouken@521: today by Lion Kimbro. slouken@521:

slouken@521:

Minor Fixes and Visual C++ 7 Information (In Green) was added by James Turk slouken@521:

slouken@521: slouken@0: