Free Borland Compiler & SDL

Chris Dion wrote:

I’ve managed to compile a simple SDL app with the free tools, however I get
a ‘Can’t create window’ error from SD_Init() when I run the app. I’m
linking with sdl.lib and sdlmain.lib, and using the -Twe compiler option.
Anyone have any ideas?

After reading your message I tried out the coff2omf program to convert the libraries. I got
the same problem you got. Forgive me for being ignorant, but I’m a little confused as to what
the coff2omf program does. The resulting libraries were very small, and the executable was
much smaller than the cross-compiled EXE of the same program. What happens to all the code?–
-= aaron p. matthews
-= rivalgames
-= http://www.rivalgames.com

Hi all,

Firstly, I saw a message in the list archives from someone having trouble
linking the SDL libs with Borland’s compiler. A quick solution is to use
the coff2omf.exe utility that comes with the compiler to convert the
sdl.lib to OMF format.

I’ve managed to compile a simple SDL app with the free tools, however I get
a ‘Can’t create window’ error from SD_Init() when I run the app. I’m
linking with sdl.lib and sdlmain.lib, and using the -Twe compiler option.
Anyone have any ideas?

Thanks,

  • Chris

Here’s the source, cut and pasted from the SDL docs ; )

#include <sdl.h>
#include <stdlib.h>

int main(int argc, char **argv) {
SDL_Surface *screen;

/* Initialize the SDL library */
if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
	fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
	exit(1);
}
/* Clean up on exit */
atexit(SDL_Quit);
/* Initialize the display in a 640x480 8-bit palettized mode */
screen = SDL_SetVideoMode(640, 480, 8, SDL_SWSURFACE);
if ( screen == NULL ) {
	fprintf(stderr, "Couldn't set 640x480x8 video mode: %s\n", SDL_GetError());
	exit(1);
}

}

After reading your message I tried out the coff2omf program to convert the
libraries. I got the same problem you got. Forgive me for being ignorant, but
I’m a little confused as to what the coff2omf program does. The resulting
libraries were very small, and the executable was much smaller than the
cross-compiled EXE of the same program. What happens to all the code?

To be honest, I’m not sure exactly what occurs. My understanding is that the
sdl.lib simply instructs the linker where it can find the functions in the
sdl.dll file. This information is then stored in the .exe, so that when the
program is run, it can call functions in that .dll. COFF is the format
VisualC++ uses to store this information, OMF is the format the Borland linker
expects. Hopefully someone will correct me if that summary is wrong.

As to the size difference, perhaps OMF is a simpler format, or perhaps the .lib
file is losing information that our programs need to run properly. I’ve looked
around in the Borland knowledge base and FAQ’s, but haven’t found anything
useful yet.

I (perhaps too hastily) deleted the behemoth that is VisualC++ from my hard
drive. It would be a real shame if SDL doesn’t (or won’t) work with the
Borland compiler. Can anyone lend a hand?

Thanks again,

  • Chris

I (perhaps too hastily) deleted the behemoth that is VisualC++ from my hard
drive. It would be a real shame if SDL doesn’t (or won’t) work with the
Borland compiler. Can anyone lend a hand?

Has anybody actually tried building a Borland makefile and building SDL?

Has anybody tried building a Borland library from the SDL export def file?

-Sam Lantinga				(slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec

Are there any instructions on how to do this… I dont really know where to
start, but if you point me in the right direction i’ll figure it out…
Thanx!!

– Uriah Liggett>From: Sam Lantinga

Reply-To: sdl at lokigames.com
To: sdl at lokigames.com
Subject: Re: [SDL] Free Borland Compiler & SDL
Date: Tue, 22 Feb 2000 19:14:50 -0800

I (perhaps too hastily) deleted the behemoth that is VisualC++ from my
hard
drive. It would be a real shame if SDL doesn’t (or won’t) work with the
Borland compiler. Can anyone lend a hand?

Has anybody actually tried building a Borland makefile and building SDL?

Has anybody tried building a Borland library from the SDL export def file?

-Sam Lantinga (slouken at devolution.com)

Lead Programmer, Loki Entertainment Software

“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec


Get Your Private, Free Email at http://www.hotmail.com

Are there any instructions on how to do this… I dont really know where to
start, but if you point me in the right direction i’ll figure it out…
Thanx!!

– Uriah Liggett

I second that. If someone could explain the steps required to build a
Borland version of the sdl.lib, I’d be happy to do it, and to write a short
doc on how to get SDL working with the free compiler. Assuming I get it
to work that is…

  • Chris Dion

Are there any instructions on how to do this… I dont really know where to
start, but if you point me in the right direction i’ll figure it out…
Thanx!!

– Uriah Liggett

I second that. If someone could explain the steps required to build a
Borland version of the sdl.lib, I’d be happy to do it, and to write a short
doc on how to get SDL working with the free compiler. Assuming I get it
to work that is…

  • Chris Dion

Are there any instructions on how to do this… I dont really know where to
start, but if you point me in the right direction i’ll figure it out…
Thanx!!

– Uriah Liggett

I second that. If someone could explain the steps required to build a
Borland version of the sdl.lib, I’d be happy to do it, and to write a short
doc on how to get SDL working with the free compiler. Assuming I get it
to work that is…

  • Chris Dion

Sorry about the multiple posts! Mail client problems…

  • Chris

Here’s a step-by-step run through of what I did. I haven’t used .dll’s and
such before, so you’ll have to excuse me if I’m not using the right
terminology.

  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 utillity 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:
ftp://ftp.borland.com/pub/bcppbuilder/techpubs/b5std.zip

I’ll try to make a sdl_main.lib that works with Borland over the next
couple days. Who do I talk to about packaging this stuff up for general
consumption?

  • Chris

P.S. I’d be happy to help anyone who’s still having problems, on or off the
mailing list.

I’ll try to make a sdl_main.lib that works with Borland over the next
couple days. Who do I talk to about packaging this stuff up for general
consumption?

I think Sam Lantinga is the person you want to talk to …–
Stefan Schmidt
Imperial College London, Department of Computing
mailto:stefan.schmidt at doc.ic.ac.uk

I’ll try to make a sdl_main.lib that works with Borland over the next
couple days. Who do I talk to about packaging this stuff up for general
consumption?

Chris, thank you for your howto - I’ve added it to the Win32 FAQ page.

I’ll be happy to help you put together a Borland C++ development runtime
to put on the SDL page.

Thanks!
-Sam Lantinga (slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec