Need a Shared Library Guru: beyond simple shared library question

Need a Shared Library Guru: beyond simple shared library question

Post by Mike Sidl » Fri, 23 Jun 1995 04:00:00



I need to come up with a shared library whose name and function names are NOT
known at compile/link time - only known at runtime. This requires the
application program to be able to dynamically load a shared library at runtime
whose name is in a variable and request a function whose name is also in
a variable.

It would work like this: At run the application program would make a system
call to dynamically load a library by the name of the string it passed. Once
loaded, the application would, using a "handle" to the library, request a
reference to a function in the library passing the name of the function. In
servicing the request the library would lookup the function name in its table
and return a pointer to the function. The application would call the function
using the pointer.

If you're familiar with Windows (I'm not that familiar with) it would be
equivalent to the "LoadLibrary" and "GetProcAddress" functions in Windows.

I've read through a number of FAQs and group posting and so far haven't come
across anything of this nature.

ANY HELP YOU CAN PROVIDE WOULD BE WELCOME!!!

TIA, Mike

--

5910 N Central Exprwy, Suite 800   phone: (214)891-6638
Dallas, TX 75206-5140              fax:   (214)987-8187

 
 
 

Need a Shared Library Guru: beyond simple shared library question

Post by Tye McQue » Fri, 23 Jun 1995 04:00:00


) It would work like this: At run the application program would make a system
) call to dynamically load a library by the name of the string it passed. Once
) loaded, the application would, using a "handle" to the library, request a
) reference to a function in the library passing the name of the function. In
) servicing the request the library would lookup the function name in its table
) and return a pointer to the function. The application would call the function
) using the pointer.

You are describing dlopen() and dlsym() [shl_load() and shl_findsym()
under HP-UX, rld_load() and rld_loojup() under NextOS].  See the "man"
for further details.
--

             Nothing is obvious unless you are overlooking something

 
 
 

1. Question: Inclusion of shared libraries during linking of shared libraries

Hi,

I am compiling a dynamic loadable library (*.so) under Unix (I'm working
under Solaris, but I guess my question applies to other Unix versions also).
This library requires other .so libraries to function. Now there are 2 ways
I can deal with this:

1.    Include the header files of the included library during compilation.
Do _not_ include the included library during linking, or
2.    Include the header files of the included library during compilation,
_and_ include the included library during linking.

Both of these work. When doing ldd on the 1st and the 2nd approach, I can
see that in the 2nd case the included libraries are required.

Can anyone tell me the pros and cons of either method? What is the preferred
way of doing this?

--
Pieter Winter
C-FAQ: http://www.eskimo.com/~scs/C-faq/top.html
C-IAQ: http://www.plethora.net/~seebs/faqs/c-iaq.html

2. Can't find a VM

3. Will strip(debug shared library) == nodebug shared library ?

4. how to install linux on my 486sx33 laptop ?

5. Help with building shared libraries with dependencies on other shared libraries

6. Max size of ext2 partition ?

7. Shared library loading shared library.

8. Help configure cron

9. When is a shared library not a shared library?

10. Shared, non shared libraries need some information about this subject

11. Shared libraries sharing from main app?

12. Compiling static libraries as shared libraries

13. Building shared library which includes static libraries