Dlopening SDL (script)

hi`

I attached a little script that will generate headers to use if you want
to dlopen SDL. Simply copy the three files to SDL/src/main/linux/dlopen
and run make. It then will create modified header files in that
directory together with two new files, SDL_dlsym.h and SDL_dldef.c.
SDL_dlsym.h can be used to easily dlsym SDL and SDL_dldef.c is used
instead of linking against SDL. See sdlopen.c for an easy example making
use of the code.

I haven’t tested it thoroughly - in fact sdlopen.c is the only test I
made, so if anyone finds it usefull or finds a bug, please drop me a
note. I guess I make use of it after testing for dlopening SDL from
OpenUT.

btw, something I noticed - the Makefile in SDL/src/main/win/exports is
missing SDL_joystick.h. Is that on purpose?–
Daniel Vogel My opinions may have changed,
666 @ http://grafzahl.de but not the fact that I am right
-------------- next part --------------
HEADERS =
…/…/…/…/include/SDL.h
…/…/…/…/include/SDL_active.h
…/…/…/…/include/SDL_audio.h
…/…/…/…/include/SDL_byteorder.h
…/…/…/…/include/SDL_cdrom.h
…/…/…/…/include/SDL_copying.h
…/…/…/…/include/SDL_endian.h
…/…/…/…/include/SDL_error.h
…/…/…/…/include/SDL_events.h
…/…/…/…/include/SDL_joystick.h
…/…/…/…/include/SDL_keyboard.h
…/…/…/…/include/SDL_keysym.h
…/…/…/…/include/SDL_main.h
…/…/…/…/include/SDL_mouse.h
…/…/…/…/include/SDL_mutex.h
…/…/…/…/include/SDL_quit.h
…/…/…/…/include/SDL_rwops.h
…/…/…/…/include/SDL_syswm.h
…/…/…/…/include/SDL_thread.h
…/…/…/…/include/SDL_timer.h
…/…/…/…/include/SDL_types.h
…/…/…/…/include/SDL_version.h
…/…/…/…/include/SDL_video.h

all:
ln -s -f …/…/…/…/include/begin_code.h begin_code.h
ln -s -f …/…/…/…/include/close_code.h close_code.h
perl genhead.pl $(HEADERS)
gcc sdlopen.c SDL_dldef.c -o sdlopen -lpthread -ldl
-------------- next part --------------
A non-text attachment was scrubbed…
Name: genhead.pl
Type: application/x-perl
Size: 1129 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20000208/94356f7d/attachment.bin
-------------- next part --------------
#include <stdio.h>

#include “SDL.h”
#include “SDL_thread.h”
#include “SDL_syswm.h”
#include “SDL_endian.h”

#include <dlfcn.h>

main(int argc, char** argv)
{
void* handle = dlopen(“libSDL.so”, RTLD_LAZY);

#define SDL_DLSYM(X) X = dlsym(handle, #X);
#include "SDL_dlsym.h"
#undef SDL_DLSYM

    if ( SDL_Init(0) < 0 ) {
            fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
            exit(1);
    }

    printf("Linked version: %d.%d.%d\n",
                    SDL_Linked_Version()->major,
                    SDL_Linked_Version()->minor,
                    SDL_Linked_Version()->patch);
    printf("This is a %s endian machine.\n",
            (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big");
    SDL_Quit();

dlclose(handle);
return 0;

}