-dlopen self

Jeff Sturm jsturm@one-point.com
Wed Mar 19 04:54:00 GMT 2003


On Tue, 18 Mar 2003, Erik Poupaert wrote:
> -export-dynamic doesn't do the trick, and linking with -dlopen self is
> rejected by gcj. Does anybody know how I can link to activate
> lt_dlopen(NULL)?

Not sure why it isn't working for you.  I tried the following example, it
definitely works on my Red Hat box:

[jsturm@suzy tmp]$ cat dltest.c
#include <stdio.h>
#include <dlfcn.h>

int x = 5;

int main(void) {
  void *handle;
  int *p;

  handle = dlopen(NULL, RTLD_GLOBAL);
  p = dlsym(handle, "x");
  if (p)
    printf("%x\n", *p);
  else
    fprintf(stderr, "%s\n", dlerror());
  return 0;
}
[jsturm@suzy tmp]$ gcc -Wall dltest.c -o dltest -Wl,--export-dynamic -ldl
[jsturm@suzy tmp]$ ./dltest
5

[jsturm@suzy tmp]$ gcc --version
gcc (GCC) 3.3 20030309 (prerelease)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

[jsturm@suzy tmp]$ ld --version
GNU ld version 2.13.90 20030308
Copyright 2002 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License.  This program has absolutely no warranty.




More information about the Java mailing list