Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <dlfcn.h>
- typedef int ( *func_ptr ) ( int x, int y );
- typedef void ( *iter_ptr ) ( int n );
- int main(void)
- {
- void *lib = dlopen( "/home/lee/Documents/Nim/libtest.so", RTLD_LAZY );
- if ( !lib ) {
- printf( "Error in lib.\n" );
- }
- func_ptr add = dlsym( lib, "add" );
- if ( !add ) {
- printf( "%s\n", dlerror() );
- }
- iter_ptr iter = dlsym( lib, "iterate" );
- if ( !iter ) {
- printf( "%s\n", dlerror() );
- }
- iter(1000);
- int a = add( 30, 30 );
- printf( "a: %d\n", a );
- dlclose( lib );
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement