Re: dlopen

New Message Reply Date view Thread view Subject view Author view

Bob Cowling (cowling++at++torus.autometric.com)
Mon, 10 Feb 1997 09:52:55 -0500


There are several ways to access the variable "g" - and someone else has
outlined how to construct the static version.

In your case, since you have two "g"s in your executable, you do want to remain
using dlopen (vs. sgidladd). This will prevent the ambiguity of which "g" is
actually being used.

Use the handle returned from the dlopen to access the variable "g" in the
second DSO.

For example (from man dlsym)

          void *handle;
          int i, *iptr;
          int (*fptr)(int);

          /* open the needed object */
          handle = dlopen("/usr/mydir/libx.so", RTLD_LAZY);

          /* find address of function and data objects */
          fptr = (int (*)(int))dlsym(handle, "some_function");

          iptr = (int *)dlsym(handle, "int_object");

          /* invoke function, passing value of integer as a parameter */

          i = (*fptr)(*iptr);

DSOs are Cool!

Bob

-- 
--------------------------------------------------------------------
Robert Cowling                                cowling++at++autometric.com
Director, Product Engineering                         (703) 658-4035
=======================================================================
List Archives, FAQ, FTP:  http://www.sgi.com/Technology/Performer/
            Submissions:  info-performer++at++sgi.com
        Admin. requests:  info-performer-request++at++sgi.com

New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:54:37 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.