Re: DLLs [OFFTOPIC]

Zachary Amsden (amsdenz@aavid.com)
Thu, 16 Jul 1998 15:31:12 -0400


-----Original Message-----
From: Erik Andersen <andersen@inconnect.com>
To: Chris Wedgwood <chris@cybernet.co.nz>
Cc: sroy@wipinfo.soft.net <sroy@wipinfo.soft.net>; Linux Newsgroup <linux-kernel@vger.rutgers.edu>
Date: Thursday, July 16, 1998 2:57 PM
Subject: Re: DLLs [OFFTOPIC]

>This facilitates certain types of programming. The question then
>was probably, what Linux APIs can be used for late binding of a
>library (comparable to the above mentioned windows APIs).
>
>I don't know the answer, and this is off topic, but I would be
>interested in knowing the answer as well.

man 3 dlopen says more than I can.
make sure you link against libdl

Sample late binding:
#include <dlfcn.h>

typdef int *Function(int);

void main(void)
{
void *hn;
Function foo;

if (!(hn = dlopen("mydll.so", O_RDONLY))) {
printf("dlopen: %s\n", dlerror());
exit(-1);
}
if (!(foo = dlsym(hn, "func_bar"))) {
printf("dlsym: %s\n", dlerror());
exit(-1);
}
printf("func_bar(1) from mydll.so returned %d\n",
(*foo)(1));
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html