Shared libraries

The first thing you'll need to do is to ensure that the shared objects required by the various drivers you'll be running are present.

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, except include the shared library into the image. This is done by simply specifying the name of the shared library on a line by itself, meaning "include this file."

Note: The runtime linker is expected to be found in a file called ldqnx.so.2, but the runtime linker is currently contained within the libc.so file, so we would make a process manager symbolic link to it.

The following buildfile snippet applies:

# include the C shared library
libc.so
# create a symlink called ldqnx.so.2 to it
[type=link] /usr/lib/ldqnx.so.2=/proc/boot/libc.so

There are several ways to determine the shared objects to include in your system image.

On the target system, you can use the ldd ("list dynamic dependencies") utility or the DL_DEBUG environment variable.

The ldd ("list dynamic dependencies") utility lists the shared objects that the program you specify requires. For example:
# ldd `which ping`
/usr/bin/ping:
        libsocket.so.3 => /lib/libsocket.so.3 (0xb8200000)
        libc.so.3 => /usr/lib/ldqnx.so.2 (0xb0300000)

The DL_DEBUG environment variable causes the shared library loader to display debugging information about the 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 dlopen() in the QNX Neutrino C Library Reference.

On the host, you can use the objdump utility, which 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.3

The ping executable needs libsocket.so.3 and libc.so.3. You then need to use objdump recursively to see what these shared objects need:

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

The libsocket.so.3 shared object needs only libc.so.3 and libc.so.3 needs nothing.