DLL Programmer's Guide for TNS/R Systems
Advanced DLL Facility Controls
DLL Programmer’s Guide for TNS/R Systems—522203-002
5-9
Running the Linker Through the Compiler
These compiler drivers will also run the linker when building a DLL, if you use the
SHARED rather than the CALL_SHARED option. For example:
nmc /in mylibc/ mylib;suppress,shared,symbols
This example compiles a program that uses that DLL:
nmc /in myprog2c/ myprog2;suppress,runnable, &
call_shared,symbols,search "mylib"
The search pragma causes the "mylib" to be included in the linker command stream.
A more flexible way to add linker commands through the compiler command line is the
pragma LINKFILE. For example, suppose that you create an edit file named obeyrld
that contains one line,
-lib zrldsrl
Then the following example will link a program that requires the dynamic loader library
(in addition to the usual libraries that are provided automatically):
nmc /in mydynpc/ mydynp;suppress,runnable, &
call_shared,symbols,linkfile "obeyrld"
OSS
The c89 compiler will run the linker for each module it compiles, unless the -c option is
present. It is somewhat more flexible in allowing you to specify linker commands to the
compiler:
•
The -L and -l options are passed straight through, with their arguments.
•
Several other linker options are recognized in -W form; run c89 with no command
input to see a list.
•
The -Wld=args option passes args into the ld command stream. For example:
•
The -Wld_obey=file option passes the named file as an obey file for the linker.
Here's an example that compiles and links a DLL:
c89 dllx.c -o dllx.so -Wshared
(Note that .so is the conventional extension for a DLL on OSS.)
This example compiles and links a program that uses that DLL and also uses dynamic
loading:
c89 prg.c -o prg -Wcall_shared dllx.so -l zrldsrl
pass a parameterless option: -Wld=-verbose
pass an input filename -Wld=foo.so
pass a sequence of tokens including blanks -Wld="-set floattype neutral_float"