Skip to content
tgashby edited this page Jan 23, 2012 · 15 revisions

Your best bet is to use LazyFoo, in the Helpful Links section.

You can try these...

Windows

  1. Compile or acquire SDL.lib, SDLmain.lib, SDL.dll
  2. Make a VS Empty Project
  3. Add your sources/headers
  4. Open 'Project Properties'
  5. 'C/C++' -> 'General' -> 'Additional Include Directories' : *path to*/SDL/includes
  6. 'Linker' -> 'Input' -> 'Additional Dependencies' : *path to*/SDL/VisualC/SDL/Win32/Debug/SDL.lib, *path to*/SDL/VisualC/SDLmain/Win32/Debug/SDLmain.lib, OpenGL32.lib
  7. 'Linker' -> 'Advanced' -> 'Entry Point' : main

Mac OS X

  1. Compile or acquire SDL.framework
  2. Create a new XCode Application->Console Tool Project
  3. Add your sources/headers
  4. Click on the project title
  5. Click on the only Target
  6. Add all your sources to 'Compile Sources'
  7. Open 'Link Binary With Libraries'
  8. Add SDL.framework, OpenGL.framework

Linux

  1. Best to compile the sources yourself.
  2. g++ myfile.cpp -o myawesomeprogram -lGL $(sdl-config --cflags --libs)

Note that 'make install' in the 1.3 SDL libraries does not install them to the standard place. The header files are /usr/local/include and the libraries themselves are installed to /usr/local/lib. So, compiling and running might look like this (see: http://www.network-theory.co.uk/docs/gccintro/gccintro_25.html ):

  1. (First, add a new file to /etc/ld.so.conf.d/ that contains the line /usr/local/lib)
  2. g++ -L/usr/local/lib/ -lSDL -lGL SDLExample.cpp -o example
  3. LD_LIBRARY_PATH=/usr/local/lib
  4. export LD_LIBRARY_PATH
  5. ./example

It would be better to statically link the libraries.

Here's the text the displays when you install the library. Libraries have been installed in: /usr/local/lib

If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the `-LLIBDIR' flag during linking and do at least one of the following:

  • add LIBDIR to the `LD_LIBRARY_PATH' environment variable during execution
  • add LIBDIR to the `LD_RUN_PATH' environment variable during linking
  • use the `-Wl,-rpath -Wl,LIBDIR' linker flag
  • have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for more information, such as the ld(1) and ld.so(8) manual pages.

Clone this wiki locally