Solved

HP-UX : shl_load & related functions

Posted on 1998-11-25
5
628 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
windows 10 how make picture as desktop background 2 73
sumHeights2  challenge 7 139
Authenticate using sesu from script 7 159
Problem to Office 1 67
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

738 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