SDL and VC++ 5.0

Well, hoping this hasn’t been discussed before (I’ve only been on
the mailing list for a couple of days) …

I have had problems trying to link in the pre-built SDL 0.5 and

0.6c DLL’s with a couple of simple SDL programs I’ve written using VC++
5.0 SP 3. Basically, VC++ 5.0 doesn’t recognize the filetype as a valid
library. I was working on getting VC++ 5.0 to recompile the source to
make my own DLLs by munging together my own Makefile, when suddenly, I
realized I needed the DirectX 5.x headers which I can no longer get
(thanks Microsoft!). I do have the DirectX 5.x run-time DLLs installed,
however.

Now, I'm going to probably have to buy the DirectX SDK sooner or

later, but I thought I could circumvent this process by just using the SDL
librarys and headers and skip DirectX for a while. I was wondering
whether anybody else has gotten the pre-built DLLs to work under VC++ 5.0
(I could be doing something extremely wrong, its been known to happen), or
whether anybody has tried to compile the DLLs themselves using VC++ 5.0.

Regards,

Steven Engelhardt
@Steven_Engelhardt
http://www.uiuc.edu/ph/www/sengelha

Computers are useless; they can only give answers.
                                -- Picasso

I have had problems trying to link in the pre-built SDL 0.5 and
0.6c DLL’s with a couple of simple SDL programs I’ve written using VC++
5.0 SP 3. Basically, VC++ 5.0 doesn’t recognize the filetype as a valid
library.

Yep. I have been using a gcc cross-compiler from Linux (both free) since
I don’t own VC++. Unfortunately, this means that the static libraries I
create are not compatible with VC++.

There’s good news though. If you want just the DirectX or WinDIB SDL
dynamic link library, you can avoid the DirectX detection code (or simplify
it to:
handle = LoadLibrary(“DDRAW.DLL”);
if ( handle != NULL ) {
FreeLibrary(handle);
… load DirectX DLL
} else {
… load WinDIB DLL
}

This will allow you to compile the stub library into a .lib using VC++,
without the DirectX headers, since it’s pretty simple code.

Now, I haven’t tried it, so you might have to tweak it.

Copy SDL/src/stub/load.c and SDL/src/stub/win32/winmain.c to a directory,
create a .LIB project out of them, and make it. Now you should be able
to write an SDL program normally, linking with your .lib instead of my
.a archive, and it will use the prebuilt DLLs at runtime.
Please test this with the programs in SDL/test/

If you get a .lib working, please let me know. I’d like to include it
so other people using VC++ can use SDL. Not everybody runs Linux. grin

StarCraft is pretty cool… grin

See ya!
-Sam Lantinga (slouken at devolution.com)–
Author of Simple DirectMedia Layer -
http://www.devolution.com/~slouken/SDL/

I have had problems trying to link in the pre-built SDL 0.5 and
0.6c DLL’s with a couple of simple SDL programs I’ve written using VC++
5.0 SP 3. Basically, VC++ 5.0 doesn’t recognize the filetype as a valid
library. I was working on getting VC++ 5.0 to recompile the source to
make my own DLLs by munging together my own Makefile, when suddenly, I
realized I needed the DirectX 5.x headers which I can no longer get
(thanks Microsoft!). I do have the DirectX 5.x run-time DLLs installed,
however.

Well, I have some instructions for building SDL applications using
Borland C++ 5.0

Only one problem. The executables they generate don’t work. :slight_smile:

But, that might just be a borland problem.
The same idea should work with VC++ and the new SDL 0.6e archive.

Please let me know if this works:

  1. Create a new project for the static library (SDL.lib)
    Copy the files:
    src/stub/load.c
    src/stub/exports.decl
    src/stub/win32/sysdep.decl
    to the directory for your project, and add the file load.c to the project.
    Add NO_DIRECTX_HEADERS to the C defines for your project.
    Add the SDL include directory to the search path for your project.

  2. Build the library SDL.lib

  3. Create a new project for your SDL application.
    Add the file
    src/stub/win32/winmain.c
    to your project, along with your normal source files.
    Add the SDL static library you created in step 2 to your project.
    Add the SDL include directory to the search path for your project.

  4. Build your application.

  5. Copy the SDL Dynamic Link Libraries from lib.win32/x86/*.dll to
    the directory containing your application.

  6. Run!–

If those don’t work, try copying the .decl files, winmain.c, and load.c
into your project and linking them that way instead of as a separate lib.

Please let me know how it goes, if you want to try this.

See ya!
-Sam Lantinga (slouken at devolution.com)


Author of Simple DirectMedia Layer -
http://www.devolution.com/~slouken/SDL/