4 typedef int (*func
)(int, int);
5 func add
, sub
, mul
, div
;
10 void *arithHandle
= NULL
;
12 arithHandle
= dlopen("libarithmetic.so", RTLD_NOW
);
13 if ( NULL
== arithHandle
)
15 printf("Arithmetic library cant be opened\n");
18 add
= (func
) dlsym (arithHandle
, "add");
19 sub
= (func
) dlsym (arithHandle
, "sub");
20 mul
= (func
) dlsym (arithHandle
, "mul");
21 div
= (func
) dlsym (arithHandle
, "div");
23 printf("Add :: %d\n", add(a
, b
));
24 printf("Sub :: %d\n", sub(a
, b
));
25 printf("Mul :: %d\n", mul(a
, b
));
26 printf("Div :: %d\n", div(a
, b
));
28 dlclose(arithHandle
); //Its important to call dlclose() when you are done
This page took 0.676593 seconds and 4 git commands to generate.