Solved

HP-UX : shl_load & related functions

Posted on 1998-11-25
5
620 Views
Last Modified: 2013-12-26
If anybody could explain the advantages of using explicit
run time dynamic linking in HP-UX programs(using shl_load or
dlopen functions) over implicit linking using linker options
e.g in GCC compiler i am using following options.
gcc -c -fPIC -shared -export-dynamic -o <lib.so>
then linking it with any other program using the functions &
data defined in <lib.so>
Please tell me any code sample if possible to show proper use of shl_load or related functions.

With Best Regards,
Flower
0
Comment
Question by:flower020397
  • 3
  • 2
5 Comments
 
LVL 2

Expert Comment

by:seedy
ID: 1294460
The same advantages that a 'LoadLibrary' and 'GetProcAddress' provide under Windows.
Lets assume we are building a product under windows that interfaces to one ore more mail services, like MAPI, VIM or SMTP.
Lets also assume that you do this depending on user's choice.  Normally, these service APIs are in seperate DLLs (MAPI32.DLL or WINSOCK.DLL, etc).

If you code does explicit LoadLibrary, and then GetProcAddress to get function pointer and call the fucniton via the pointer.  In this case, when the product is installed on a users' machine, it will interface with only the mail interface that machine provides.  For example, if the user does not have MAPI32.DLL or VIM.DLL, but has only WINSOCK, you program will still work fine.

On the other hand, if you have "implicitly linked" the DLLs than, the product will not run, if any of these DLLs are not found.  (Lets' say, VIM.DLL is not available).

The same will hold good for HP-UX.  Replace "shl_load" for 'LoadLibray' and 'shl_findsym' for 'GetProcAddress'.
But the dynamic/shared libraries (or the linker) on most UNIX have few additional feature than on the Windows.  For example, you can use -B option of HP-UX linker to specify run-time binding behavior of a program using shared libraries.  For more info man "ld".
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 200 total points
ID: 1294461
> On the other hand, if you have "implicitly linked" the DLLs than, the product will not run, if any of  these DLLs are not found.
NO, this depends on the linker options: -B defered  or  -B immediate  or  -B nonfatal

> But the dynamic/shared libraries (or the linker) on most UNIX have few additional feature than  on the Windows.
I would state the other way around, see comment about -B option  ;-))

----------------------
The advantage using implicit linking is that there is only one precondition at runtime: the linked libs must exist (but see -B option also).
You don't need anything special in your code for this behavior.

While the advantage of using shl_load, dlopen etc. has the advantage that you can
load any kind of shared object dynamically from within your code. You don't need to have the libs (and its functions) at compile- and runtime.
0
 
LVL 2

Expert Comment

by:seedy
ID: 1294462
ahoffmann:
>On the other hand, if you have "implicitly linked" the DLLs than, the product will not run, if any of these DLLs are not found.

I was still talking about Windows.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 1294463
aha, so it's time to tell us the "Windows features" ;-)
0
 
LVL 2

Expert Comment

by:seedy
ID: 1294464
ahoffmann:
>On the other hand, if you have "implicitly linked" the DLLs than, the product will not run, if any of these DLLs are not found.

I was still talking about Windows.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now