HP XC System 3.x Software User Manual

Page 44

Advertising
background image

recommends an alternative method. The dynamic linker, during its attempt to load libraries, will suffix
candidate directories with the machine type. The HP XC system on the CP4000 platform uses i686 for 32-bit
binaries and x86_64 for 64-bit binaries. HP recommends structuring directories to reflect this behavior.
Therefore, if your released directory structure looks like

Example 4-1, “Directory Structure”

, then ensure that

the LD_LIBRARY_PATH has /opt/mypackage/lib in it, which will then be able to handle both 32-bit
and 64-bit binaries that have linked against libmystuff.so.

Example 4-1 Directory Structure

/opt/mypackage/include/mystuff.h

/opt/mypackage/lib/i686/libmystuff.a

/opt/mypackage/lib/i686/libmystuff.so

/opt/mypackage/lib/x86_64/libmystuff.a

/opt/mypackage/lib/x86_64/libmystuff.so

If you have an existing paradigm using different names, HP recommends introducing links with the above
names. An example of this is shown in

Example 4-2

.

Example 4-2 Recommended Directory Structure

/opt/mypackage/include/mystuff.h

/opt/mypackage/lib/32/libmystuff.a

/opt/mypackage/lib/32/libmystuff.so

/opt/mypackage/lib/64/libmystuff.a

/opt/mypackage/lib/64/libmystuff.so

/opt/mypackage/lib/i686 -> 32

/opt/mypackage/lib/x86_64 -> 64

Linking an application using the library (dynamic or archive) requires you to specify the appropriate
subdirectory, depending on whether the application is 32-bit or 64-bit.

For example, to build a 32-bit application, you might enter:

<linkcommand> <32-bit> -L/opt/mypackage/lib/i686 -lmystuff

To build a 64-bit application, you might enter:

<linkcommand> <64-bit> -L/opt/mypackage/lib/x86_64 -lmystuff

Note that there is no shortcut as there is for the dynamic loader.

44

Developing Applications

Advertising