Is there a way to load share library dynamically in C on Unix platform?

Is there a way to load share library dynamically in C on Unix platform?

Post by Ling Wan » Tue, 10 Jun 1997 04:00:00



Does somebody know how to load shared library dynamically
in C on Unix platform?

Now I have shared library for example a.so. In my main program,
I want to call a function b() which is in a.so if the function exists.
So I need to load library first, then get the function address.
I can do it on windows. How can I do on Unix?

Ling

 
 
 

Is there a way to load share library dynamically in C on Unix platform?

Post by Doug Wyat » Tue, 10 Jun 1997 04:00:00



> Does somebody know how to load shared library dynamically
> in C on Unix platform?

> Now I have shared library for example a.so. In my main program,
> I want to call a function b() which is in a.so if the function exists.
> So I need to load library first, then get the function address.
> I can do it on windows. How can I do on Unix?

> Ling


If I understand your question correctly, there are two options.  First,
you could hack your ld.so to deal with symbols that may or may not
be defined in a .so.  Probably a better solution would be to take
a look at Wilson Ho's DLD linker.  You can get it from ucdavis.edu
although I don't have the URL off hand.  He used to be at UCDavis
but I'm not sure if he's still there (I couldn't find him in a cursory
search of their directory)

Doug Wyatt
MIT LCS

 
 
 

Is there a way to load share library dynamically in C on Unix platform?

Post by Guy Harr » Wed, 11 Jun 1997 04:00:00



Quote:>If I understand your question correctly, there are two options.
>First, you could hack your ld.so to deal with symbols that may or may not
>be defined in a .so.

...or you could just use the facility that most "ld.so"s already have,
namely "dlopen()" and "dlsym()" (the latter deals with symbols that
aren't defined by returning NULL).

Not all UNIXes have "dlopen()", "dlsym()", and company, although I
suspect the few modern UNIXes that are holdouts will add it (either by
adding dynamic linking features, or adding "dlopen()"/"dlsym()"/etc.
calls to their existing dynamic linking mechanisms).

If you have a non-modern UNIX, you may have to grab "dld".
--
Reply, or follow up, but don't do both, please.



 
 
 

Is there a way to load share library dynamically in C on Unix platform?

Post by Guy Harr » Wed, 11 Jun 1997 04:00:00



>If you have a non-modern UNIX, you may have to grab "dld".

I think Wilson Ho is now at SGI (working on their dynamic linking code,
among other things, as I remember...).
--
Reply, or follow up, but don't do both, please.



 
 
 

Is there a way to load share library dynamically in C on Unix platform?

Post by Frederic MARA » Wed, 11 Jun 1997 04:00:00



>Does somebody know how to load shared library dynamically
>in C on Unix platform?
>Now I have shared library for example a.so. In my main program,
>I want to call a function b() which is in a.so if the function exists.
>So I need to load library first, then get the function address.
>I can do it on windows. How can I do on Unix?
>Ling


On AIX, you can use the load/unload subroutines to dynamically link-in
libraries (or even executables !) to your code.
-------------------------
   Frederic G. MARAND
  Agorus SA / OSI SARL

-------------------------
 
 
 

Is there a way to load share library dynamically in C on Unix platform?

Post by Brian McCaule » Fri, 13 Jun 1997 04:00:00



> Does somebody know how to load shared library dynamically
> in C on Unix platform?

dlopen()

[ Assuming your platform supports it. ]

--

 .  _\\__[oo       from       | Phones: +44 121 471 3789 (home)

.  l___\\    /~~) /~~[  /   [ | PGP-fp: D7 03 2A 4B D8 3A 05 37...
 # ll  l\\  ~~~~ ~   ~ ~    ~ | http://wcl-l.bham.ac.uk/~bam/