Linking your modules

To link your application against a library, use the -l option to qcc, omitting the lib prefix and any extension from the library's name. For example, to link against libsocket, specify -l socket.

You can specify more than one -l option. The qcc configuration files might specify some libraries for you; for example, qcc usually links against libc. The description of each function in the QNX Neutrino C Library Reference tells you which library to link against.

The QNX Neutrino linker is a single-pass linker, so you must list all libraries after all objects (.o files) on the link line. If one library (say, lib1.a) has functions that call functions in another library (say, lib2.a), then put lib1.a before lib2.a) on the link command line.

By default, the tool chain links dynamically. We do this because of all the benefits mentioned above.

If you want to link everything statically, specify the -static option to qcc, which causes the link stage to look in the library directory only for static libraries (identified by a .a extension).

Note: For this release of QNX Neutrino, you can't use the floating point emulator ( in statically linked executables.

Although we generally discourage linking statically, it does have this advantage: in an environment with tight configuration management and software QA, the very same executable can be regenerated at link time and known to be complete at runtime.

To link dynamically (the default), you don't have to do anything.

To link statically and dynamically (some libraries linked one way, other libraries linked the other way), the two keywords -Bstatic and -Bdynamic are positional parameters that can be specified to qcc. All libraries specified after the particular -B option are linked in the specified manner. You can have multiple -B options:

qcc ... -Bdynamic -l1 -l2 -Bstatic -l3 -l4 -Bdynamic -l5

This causes libraries lib1, lib2, and lib5 to be dynamically linked (i.e., qcc links against the files, and, and libraries lib3 and lib4 to be statically linked (i.e., qcc links against the files lib3.a and lib4.a).

You may see the extension .1 appended to the name of the shared object (e.g., This is a version number. Use the extension .1 for your first revision, and increment the revision number if required.

You may wish to use the above "mixed-mode" linking because some of the libraries you're using are needed by only one executable or because the libraries are small (less than 4 KB), in which case you'd be wasting memory to use them as shared libraries. Note that shared libraries are typically mapped in 4-KB pages and require at least one page for the "text" section and possibly one page for the "data" section.

Note: When you specify -Bstatic or -Bdynamic, all subsequent libraries are linked in the specified manner.