Solved

HP-UX : shl_load & related functions

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Folder Comparison 12 53
Define unique primary key 9 89
if loop in java 3 128
java ^ examples 8 62
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

932 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

15 Experts available now in Live!

Get 1:1 Help Now