Skip to content
/ shell Public

S(ymbol) H(elper) is a basic STB-Style for the WIN32 LoadLibrary and POSIX dlopen functions to maintain a basic yet consistent API for both platforms.

License

Notifications You must be signed in to change notification settings

lxmcf/shell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

(SH)ell

S(ymbol) H(elper) is a basic STB-Style for the WIN32 LoadLibrary and POSIX dlopen functions to maintain a basic yet consistent API for both platforms.

Building Examples

Linux/MacOS Steps:

cc -Wall -Wextra -ldl -Isrc/ example/main.c -o application
cc -shared -fPIC -Wall -Wextra -Isrc example/lib.c -o lib.so

./application

Windows Steps: *

cl /Feapplication.exe /I"src" example/main.c
cl /Felib.dll /LD /I"src" example/lib.c

.\application.exe

Note: All Windows testing was performed using PortableBuildTools and not tested using Visual Studio

Example Code

// main.c
#define SH_IMPLEMENTATION
#include <sh.h>

int main () {
    SH_LibHandle lib = SH_LoadLibraryEx (SH_LOCAL_DIR, SH_LIBNAME ("lib"));

    SH_VoidFunction test_function = SH_GetSymbol (lib, "LIB_TestFunction");

    if (test_function != NULL) {
        test_function ();
    }

    SH_CloseLibrary (lib);

    return 0;
}
// lib.c
#include <sh.h>
#include <stdio.h>

SH_EXPORT void LIB_TestFunction () {
    printf ("Hello from LIB_TestFunction!\n");
}

About

S(ymbol) H(elper) is a basic STB-Style for the WIN32 LoadLibrary and POSIX dlopen functions to maintain a basic yet consistent API for both platforms.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages