Compile and link your code with the native compiler for the target platform. For UNIX, use the gmake command. For Windows, use the nmake command. For Windows, use Microsoft Visual C++ 6.0 or newer. You must have an import list that specifies all global variables and functions to access from the server binary. Use the correct compiler and linker flags for your platform. Refer to the example Makefile in the server_root/plugins/nsapi/examples directory.
Adhere to the following guidelines for compiling and linking.
Add the server_root/plugins/include (UNIX) or server_root\plugins\include (Windows) directory to your makefile to include the nsapi.h file.
Add the server_root/bin/https/lib (UNIX) or server_root\bin\https\bin (Windows) library directory to your linker command.
The following table lists the library that you need to link to.
Table 3–1 Libraries
Platform |
Library |
---|---|
Windows |
ns-httpd40.dll (in addition to the standard Windows libraries) |
HP-UX |
libns-httpd40.sl |
All other UNIX platforms |
libns-httpd40.so |
To generate a shared library, use the commands and options listed in the following table.
Table 3–2 Linker Commands and Options
Platform |
Options |
---|---|
Solaris™ Operating System (SPARC® Platform Edition) |
ld -G or cc -G |
Windows |
link -LD |
HP-UX |
cc +Z -b -Wl,+s -Wl,-B,symbolic |
AIX |
cc -p 0 -berok -blibpath:$(LD_RPATH) |
Compaq |
cc -shared |
Linux |
gcc -shared |
IRIX |
cc -shared |
Use the linker flags in the following table to specify which directories should be searched for shared objects during runtime to resolve symbols.
Table 3–3 Linker Flags
Platform |
Flags |
---|---|
Solaris SPARC |
-R dir:dir |
Windows |
(no flags, but the ns-httpd40.dll file must be in the system PATH variable) |
HP-UX |
-Wl,+b,dir,dir |
AIX |
-blibpath:dir:dir |
Compaq |
-rpath dir:dir |
Linux |
-Wl,-rpath,dir:dir |
IRIX |
-Wl,-rpath,dir:dir |
On UNIX, you can also set the library search path using the LD_LIBRARY_PATH environment variable, which must be set when you start the server.
The following table lists the flags and defines you need to use for compilation of your source code.
Table 3–4 Compiler Flags and Defines
Parameter |
Description |
---|---|
Solaris SPARC |
-DXP_UNIX -D_REENTRANT -KPIC -DSOLARIS |
Windows |
-DXP_WIN32 -DWIN32 /MD |
HP-UX |
-DXP_UNIX -D_REENTRANT -DHPUX |
AIX |
-DXP_UNIX -D_REENTRANT -DAIX $(DEBUG) |
Compaq |
-DXP_UNIX -KPIC |
Linux |
-DLINUX -D_REENTRANT -fPIC |
IRIX |
-o32 -exceptions -DXP_UNIX -KPIC |
All platforms |
-MCC_HTTPD -NET_SSL |
The following table lists the optional flags and defines you can use.
Table 3–5 Optional Flags and Defines
Flag/Define |
Platforms |
Description |
---|---|---|
-DSPAPI20 |
All |
Needed for the proxy utilities function include file putil.h |
For AIX only, plug-ins built for 3.x versions of the server must be relinked to work with 4.x and 6.x versions. The files you need, which are in the server_root/plugins/nsapi/examples/ directory, are as follows:
The Makefile file has the -G option instead of the old -bM:SRE -berok- brtl -bnoentry options.
A script, relink_36plugin, modifies a plug-in built for 3.x versions of the server to work with 4.x and 6.x versions. The script’s comments explain its use.
Sun Java System Web Server 4.x and 6.x versions are built on AIX 4.2, which natively supports runtime-linking. Because of this, NSAPI plug-ins, which reference symbols in the ns-httpd main executable, must be built with the -G option, which specifies that symbols must be resolved at runtime.
Previous versions of Sun Java System Web Server, however, were built on AIX 4.1, which did not support native runtime-linking. Sun Java System Web Server had specific additional software to enable plug-ins. No special runtime-linking directives were required to build plug-ins. Because of this, plug-ins that have been built for previous server versions on AIX will not work with Sun Java System Web Server 4.x and 6.x versions as they are.
However, they can easily be relinked to work with Sun Java System Web Server 4.x and 6.x versions. The relink_36plugin script relinks existing plug-ins. Only the existing plug-in itself is required for the script; original source and .o files are not needed. More specific comments are in the script itself. Since all AIX versions from 4.2 onward natively support runtime-linking, no plug-ins for Sun Java System Web Server versions 4.x and later will need to be relinked.