Home
Developer Resources
QNX RTOS v4
QNX RTOS v4 Knowledge Base

QNX RTOS v4 Knowledge Base

Foundry27
Foundry27
QNX RTOS v4 project
Resources

QNX RTOS v4 Knowledge Base

Title Making and using library files in QNX4
Ref. No. QNX.000004586
Category(ies) Utilities, Development
Issue On our QNX4 system we can't find "ar" or "renlib" that are used to create libraries on other systems.
How do you make *.lib library files?
Also once you make the libraries, how do you use them?







Solution The tools to create libraries are part of the Watcom 10.6 Compiler package. It contains "ar" and "wlib". "renlib" is not part of Watcom.

If you have a source file (mysource.c) that you want to make into a library called mylib the steps are:

1. Compile it into an object file (use -c arg).
2. wlib mylib +mysource.o

This will create mylib and place mysource in it. If it already exists it will add mysrouce to the contents of the library. If you are adding to a library make sure you have compiled with the same options as the rest of the library.

To check what is in a library, simply run wlib and the name of the lib.

"ar" exists, but is a link to wlib.

To use your new library in a program, you have a few options. You can include it on the compile line with the -l ("el") option and include the path as well as the name of the file. You don't have to include the .lib on the end, or the path if it's in the same directory as where you are compiling from. Secondly, you can put it in the /usr/lib directory with all the other libraries. This is an ok method, but you have to be sure that the library is fully functional, free of bugs, and does not conflict with other libraries, i.e. no functions with duplicate names, etc.
Third, you can create an environment variable called LIBQNX that would normally be placed in either your $HOME/.profile or /etc/profile so that when you start your computer LIBQNX is defined and ready to be used. Fourth and lastly, you can edit the /etc/default/cc file to include the path to your new lib in the default (or other) version settings. If you do not specify a -vXXX option when you compile, the default entry is run to provide paths for libraries and headers, and default options to the compiler.

See Also: Watcom Utilities
See Also: Chapter 1 and 12 from Watcom Compiler & Tools