|
Home > Archive > Unix Programming > December 2007 > dlsym() problem
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Frank Cusack 2007-12-08, 1:45 am |
| why doesn't this program work on Linux?
$ cat dltest.c
#define _GNU_SOURCE
#include <stdio.h>
#include <dlfcn.h>
int
main(int argc, char *argv[])
{
if (dlsym(RTLD_DEFAULT, "main"))
printf("main found\n");
else
printf("main not found\n");
}
$ gcc dltest.c -ldl && ./a.out
main not found
On Solaris, it works when using the Solaris linker, but fails when
using the GNU linker.
By "works", obviously I mean that the output is "main found".
-frank
| |
| fjblurt@yahoo.com 2007-12-08, 1:45 am |
| On Dec 7, 5:55 pm, Frank Cusack <fcus...@fcusack.com> wrote:
> why doesn't this program work on Linux?
>
> $ cat dltest.c
> #define _GNU_SOURCE
> #include <stdio.h>
> #include <dlfcn.h>
>
> int
> main(int argc, char *argv[])
> {
> if (dlsym(RTLD_DEFAULT, "main"))
> printf("main found\n");
> else
> printf("main not found\n");
>
> }
>
> $ gcc dltest.c -ldl && ./a.out
> main not found
>
> On Solaris, it works when using the Solaris linker, but fails when
> using the GNU linker.
>
> By "works", obviously I mean that the output is "main found".
>
> -frank
Linking with -rdynamic makes it work for me.
| |
| Frank Cusack 2007-12-08, 1:45 am |
| On Fri, 7 Dec 2007 18:42:36 -0800 (PST) fjblurt@yahoo.com wrote:
> Linking with -rdynamic makes it work for me.
me too. thanks.
|
|
|
|
|