Erik Hofman <[EMAIL PROTECTED]> writes:

> Alex Romosan wrote:
>
>> you are mixing static and dynamic linking. andy is talking about
>> dynamic linking. i am not sure what you are talking about.
>
> Statically linking a shared-object library only means it gets
> dynamically linked upon program start. There is a way to do delayed
> static linking, but that is only useful for programs that require a
> shared-object library under certain circumstances (say when a menu
> item is selected), but not by default.

a better fix, which i think will work on both linux and irix is to
call the dlopen() with a null pathname. the returned handle will then
be for the main program including the libraries linked dynamically. so
the correct version of SGLookupFunction() for unix should be (modulo
the other OSs):

inline void (*SGLookupFunction(const char *func))()
{
  void *handle;
  void (*fptr)();

  handle = dlopen (0, RTLD_LAZY);
  if (!handle) {
    fprintf (stderr, "%s\n", dlerror());
    exit(1);
  }

  dlerror();    /* Clear any existing error */
  fptr = (void (*)()) dlsym(handle, func);
  if ((error = dlerror()) != NULL)  {
    fprintf (stderr, "%s\n", error);
    exit(1);
  }
  dlclose(handle);
  return fptr;
}

tested only on linux as i don't have access to an irix system (but the
man page at
http://www.chemie.fu-berlin.de/cgi-bin/man/sgi_irix?dlopen+3 leads me
to believe it should also work on irix). hope this helps.

--alex--

-- 
| I believe the moment is at hand when, by a paranoiac and active |
|  advance of the mind, it will be possible (simultaneously with  |
|  automatism and other passive states) to systematize confusion  |
|  and thus to help to discredit completely the world of reality. |

_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel

Reply via email to