Solved

HP-UX : shl_load & related functions

Posted on 1998-11-25
5
624 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Expand LInux Boot partition remotly 3 90
ORA-01403: no data found 43 101
Hibernate methods 2 71
Doc'in system (example?) BA 7 110
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

770 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