Page 1 of 1

dynamic libraries example

Posted: Mon Apr 25, 2011 1:11 am
by Antonio Linares
gcc test.c -o test
./test

test.c

Code: Select all

#include <stdio.h>
#include <dlfcn.h>

void hb_vmInit( int );

int main( char * arg, int args )
{
    void * handle = dlopen ( "libharbour.2.1.0.dylib", RTLD_LAZY );
    void ( * hb_vmInit ) ( int );

    hb_vmInit = dlsym( handle, "hb_vmInit" );
    ( * hb_vmInit )( 1 );

    dlclose( handle );

    return 0;
}