Home | History | Annotate | Download | only in sdl-1.2.15
      1 <HTML>
      2 	<HEAD>
      3 		<TITLE>Using SDL with Microsoft Visual C++</TITLE>
      4 	</HEAD>
      5 	<BODY>
      6 		<H1>
      7 			Using SDL with Microsoft Visual C++ 5,6&nbsp;and 7
      8 		</H1>
      9 		<H3>
     10 			by <A HREF="mailto:snowlion (a] sprynet.com">Lion Kimbro </A>and additions by <A HREF="mailto:james (a] conceptofzero.net">
     11 				James Turk</A>
     12 		</H3>
     13 		<p>
     14 			You can either use the precompiled libraries from <A HREF="http://www.libsdl.org/download.php">
     15 				the SDL Download web site </A>, or you can build SDL yourself.
     16 		</p>
     17 		<H3>
     18 			Building SDL
     19 		</H3>
     20 		<P>
     21 			Go into the VisualC
     22 			directory that is created, and double-click on the VC++ file "<CODE>SDL.dsw</CODE>"<STRONG><FONT color="#009900">
     23 					("<CODE>SDL.sln</CODE>").</FONT></STRONG> This should open up the IDE.
     24 		</P>
     25 		<P>
     26 			You may be prompted at this point to upgrade the workspace, should you be using 
     27 			a more recent version of Visual C++. If so, allow the workspace to be upgraded.
     28 		</P>
     29 		<P>
     30 			Build the <CODE>.dll</CODE> and <CODE>.lib</CODE> files.
     31 		</P>
     32 		<P>
     33 			This is done by right clicking on each project in turn (Projects are listed in 
     34 			the Workspace panel in the FileView tab), and selecting "Build".
     35 		</P>
     36 		<P>
     37 			If you get an error about SDL_config.h being missing, you should
     38 			copy include/SDL_config.h.default to include/SDL_config.h and try again.
     39 		</P>
     40 		<P>
     41 			You may get a few warnings, but you should not get any errors. You do have to 
     42 			have at least the DirectX 5 SDK installed, however. The latest 
     43 			version of DirectX can be downloaded or purchased on a cheap CD (my 
     44 			recommendation) from <A HREF="http://www.microsoft.com">Microsoft </A>.
     45 		</P>
     46 		<P>
     47 			Later, we will refer to the following .lib and .dll files that have just been 
     48 			generated:
     49 		</P>
     50 		<ul>
     51     <li> SDL.dll</li>
     52     <li> SDL.lib</li>
     53     <li> SDLmain.lib</li>
     54     </ul>
     55 		<P>
     56 			Search for these using the Windows Find (Windows-F) utility, if you don't 
     57 			already know where they should be. For those of you with a clue, look inside 
     58 			the Debug or Release directories of the subdirectories of the Project folder. 
     59 			(It might be easier to just use Windows Find if this sounds confusing. And 
     60 			don't worry about needing a clue; we all need visits from the clue fairy 
     61 			frequently.)
     62 		</P>
     63 		<H3>
     64 			Creating a Project with SDL
     65 		</H3>
     66 		<P>
     67 			Create a project as a Win32 Application.
     68 		</P>
     69 		<P>
     70 			Create a C++ file for your project.
     71 		</P>
     72 		<P>
     73 			Set the C runtime to "Multi-threaded DLL" in the menu: <CODE>Project|Settings|C/C++ 
     74 				tab|Code Generation|Runtime Library </CODE>.
     75 		</P>
     76 		<P>
     77 			Add the SDL <CODE>include</CODE> directory to your list of includes in the 
     78 			menu: <CODE>Project|Settings|C/C++ tab|Preprocessor|Additional include directories </CODE>
     79 			.
     80 			<br>
     81 			<STRONG><FONT color="#009900">VC7 Specific: Instead of doing this I find it easier to 
     82 					add the include and library directories to the list that VC7 keeps. Do this by 
     83 					selecting Tools|Options|Projects|VC++ Directories and under the "Show 
     84 					Directories For:" dropbox select "Include Files", and click the "New Directory 
     85 					Icon" and add the [SDLROOT]\include directory (ex. If you installed to 
     86 					c:\SDL-1.2.5\ add c:\SDL-1.2.5\include).&nbsp;Proceed to&nbsp;change the 
     87 					dropbox selection to "Library Files" and add [SDLROOT]\lib.</FONT></STRONG>
     88 		</P>
     89 			<P>
     90 				The "include directory" I am referring to is the <CODE>include</CODE> folder 
     91 				within the main SDL directory (the one that this HTML file located within).
     92 			</P>
     93 			<P>
     94 				Now we're going to use the files that we had created earlier in the Build SDL 
     95 				step.
     96 			</P>
     97 			<P>
     98 				Copy the following files into your Project directory:
     99 			</P>
    100 			<ul>
    101      <li> SDL.dll</li>
    102      </ul>
    103 			<P>
    104 				Add the following files to your project (It is not necessary to copy them to 
    105 				your project directory):
    106 			</P>
    107 			<ul>
    108      <li> SDL.lib </li>
    109      <li> SDLmain.lib</li>
    110      </ul>
    111 			<P>
    112 				(To add them to your project, right click on your project, and select "Add 
    113 				files to project")
    114 			</P>
    115 		<P><STRONG><FONT color="#009900">Instead of adding the files to your project it is more 
    116 					desireable to add them to the linker options: Project|Properties|Linker|Command 
    117 					Line and type the names of the libraries to link with in the "Additional 
    118 					Options:" box.&nbsp; Note: This must be done&nbsp;for&nbsp;each&nbsp;build 
    119 					configuration (eg. Release,Debug).</FONT></STRONG></P>
    120 		<H3>
    121 			SDL 101, First Day of Class
    122 		</H3>
    123 		<P>
    124 			Now create the basic body of your project. The body of your program should take 
    125 			the following form: <CODE>
    126 				<PRE>
    127 #include "SDL.h"
    128 
    129 int main( int argc, char* argv[] )
    130 {
    131   // Body of the program goes here.
    132   return 0;
    133 }
    134 </PRE>
    135 			</CODE>
    136 		<P></P>
    137 		<H3>
    138 			That's it!
    139 		</H3>
    140 		<P>
    141 			I hope that this document has helped you get through the most difficult part of 
    142 			using the SDL: installing it. Suggestions for improvements to this document 
    143 			should be sent to the writers of this document.
    144 		</P>
    145 		<P>
    146 			Thanks to Paulus Esterhazy (pesterhazy (a] gmx.net), for the work on VC++ port.
    147 		</P>
    148 		<P>
    149 			This document was originally called "VisualC.txt", and was written by <A HREF="mailto:slouken (a] libsdl.org">
    150 				Sam Lantinga</A>.
    151 		</P>
    152 		<P>
    153 			Later, it was converted to HTML and expanded into the document that you see 
    154 			today by <A HREF="mailto:snowlion (a] sprynet.com">Lion Kimbro</A>.
    155 		</P>
    156 		<P>Minor Fixes and Visual C++ 7 Information (In Green) was added by <A HREF="mailto:james (a] conceptofzero.net">James Turk</A>
    157 		</P>
    158 	</BODY>
    159 </HTML>
    160