How do I use SDL with Borland C++?

SDL 1.2.5 and newer have projects for C++ Builder 5 and 6 for Windows, Kylix 3, and the free Borland C++ command line tools. Take a look at Borland.html in the source archive.

Martin Bickel writes: For both Watcom C/C++ and Borland C/C++ the compiler option that makes enums having the size of an int must be enabled. This is "-b" for Borland C/C++ and "-ei" for Watcom C/C++ (v11).

Chris Dion wrote down his steps on building manually with the free command line tools:

  1. Run the IMPLIB utility on SDL.DLL to make a new SDL.LIB import library. Use the -a and -c switches.
  2. You still need the SDL_MAIN.LIB file, so that you don't need to define WinMain() and all that junky windows stuff. You have no .dll file to build this .lib from, and COFF2OMF creates a empty .lib (you can check with TDUMP, another utility that comes with the compiler). Get the Win32 version of the SDL_main.c file from the source, and dump it in with the rest of your project.

  3. Compile your source (including SDL_main.c) into object files using BCC32 with the following compiler options:
    • -c (Don't link) -tW (Create windows app) -DWIN32 (Define WIN32, this is needed in the SDL_main.h file, and maybe others)
  4. Link the.obj files together using ILINK32 with the following options:
    • -aa (Create windows app, sounds redundant, but...) -Tpe (Target = windows exe) -c (case sensitive linking, may be the default...)
    • and the following additional files (order is important)
      • sdl.lib (created in step 1)
      • import32.lib
      • c0w32.obj
      • cw32.lib

If all goes well, you should have a working .exe file. The help files that come with the command line tools are missing detailed descriptions of the various compiler/linker switches. You can download a complete help file from the Borland ftp site here:

FAQ_Compiling_on_Borland_C++ (last edited 2008-04-17 08:18:16 by localhost)