Shared libraries

Your buildfile must tell the build process to include in the image all of the shared objects required by the drivers you'll be running.

Including shared objects

All drivers require at least the standard C library shared object (libc.so). Since the shared object search order looks in /proc/boot, you don't have to do anything special. Just specify the name of the shared object on a line by itself; this means “include this file”.

To include the runtime linker, we create a process manager symbolic link to it in /proc/boot/.

The following buildfile snippet instructs the build process to include the C library shared object and ldqnx-64.so.2:

# include the C shared library and GCC's low-level runtime library
libc.so
libgcc_s.so.1
/usr/lib/ldqnx-64.so.2=ldqnx-64.so.2

Automatically

You can use the mkifs autoso attribute to list all shared libraries needed by the binaries specified in your buildfile, or even to automatically add them to your IFS. For more information, see Adding missing shared libraries automatically in the “OS Image Buildfiles” chapter of this guide, and the mkifs autoso attribute in the Utilities Reference.

Determining which shared objects you need

There are several ways to determine which shared objects you need to include in your system image.

On the target

On the target system, you can use the ldd utility, or the DL_DEBUG environment variable.

The ldd (“list dynamic dependencies”) utility lists the shared objects required by the program you specify. For example:

# ldd `which ping`
/usr/bin/ping:
        libsocket.so.3 => /lib/libsocket.so.3 (0xb8200000) 
        libc.so.5 => /usr/lib/ldqnx.so.2 (0xb0300000)

You can set the DL_DEBUG environment variable. This causes the shared library loader to display debugging information about libraries as they're opened. For example:

# export DL_DEBUG=libs
# ping 10.42.110.235
load_object: attempt load of libsocket.so.3
load_elf32: loaded lib at addr b8200000(text) b822bccc(data)
dlopen("nss_files.so.0",513)
load_object: attempt load of nss_files.so.0
dlopen: Library cannot be found
dlopen("nss_dns.so.0",513)
load_object: attempt load of nss_dns.so.0
dlopen: Library cannot be found

For more information about the values for DL_DEBUG, see the entry for dlopen() in the QNX Neutrino C Library Reference.

On the host

The objdump utility displays information about the executables you're including in the image; look for the objects marked as NEEDED. For example:

$ ntox86_64-objdump -x x86_64/usr/bin/ping | grep NEEDED
  NEEDED               libsocket.so.3
  NEEDED               libc.so.5

The ping executable needs libsocket.so.3 and libc.so.5.

You then need to use objdump recursively to see what other shared objects these shared objects need:

$ ntox86_64-objdump -x x86_64/lib/libsocket.so.3 | grep NEEDED
  NEEDED               libc.so.5
$ ntox86_64-objdump -x x86_64/lib/libc.so.5 | grep NEEDED

The libsocket.so.3 shared object needs only libc.so.5, which, in turn, needs nothing.

Automatically

As explained above, the mkifs autoso attribute lets you list all shared libraries needed by the binaries in your IFS, or automatically add them to your IFS. For more information, see the Adding missing shared libraries automatically section in this guide, and the mkifs autoso attribute in the Utilities Reference.