2 Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
13 /* Test program to test dynamic loading with the loadso subsystem.
22 typedef int (*fntype) (const char *);
24 main(int argc, char *argv[])
28 const char *libname = NULL;
29 const char *symname = NULL;
34 const char *app = argv[0];
35 SDL_Log("USAGE: %s <library> <functionname>\n", app);
36 SDL_Log(" %s --hello <lib with puts()>\n", app);
41 if (SDL_Init(0) < 0) {
42 SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
46 if (strcmp(argv[1], "--hello") == 0) {
55 lib = SDL_LoadObject(libname);
57 SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadObject('%s') failed: %s\n",
58 libname, SDL_GetError());
61 fn = (fntype) SDL_LoadFunction(lib, symname);
63 SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadFunction('%s') failed: %s\n",
64 symname, SDL_GetError());
67 SDL_Log("Found %s in %s at %p\n", symname, libname, fn);
69 SDL_Log("Calling function...\n");
71 fn(" HELLO, WORLD!\n");
72 SDL_Log("...apparently, we survived. :)\n");
73 SDL_Log("Unloading library...\n");
77 SDL_UnloadObject(lib);