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 install_dir/samples/nsapi directory.
Adhere to the following guidelines for compiling and linking.
Add the install_dir/include (UNIX) or install_dir\include (Windows) directory to your makefile to include the nsapi.h file.
Add the install_dir/bin/https/lib (UNIX) or install_dir\bin\https\bin (Windows) library directory to your linker command.
The following table lists the library that you need to link to.
Table 1–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 1–2 Linker Commands and Options
Platform |
Options |
---|---|
SolarisTM 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 1–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 1–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 |
-DXP_UNIX -D_REENTRANT -fPIC |
IRIX |
-o32 -exceptions -DXP_UNIX -KPIC |
On Solaris, the server can run in either 32–bit or 64–bit mode. Because a 32–bit shared library cannot be used in a 64–bit process and conversely, you may wish to compile and link two separate shared libraries. By default, the Sun compiler and linker produce 32–bit binaries. To compile and link your plug-in for 64–bit mode on Solaris SPARC, you must use Sun Workshop 5.0 or higher with the -xarch=v9 flag. To compile and link your plug-in for 64–bit mode on Solaris x86, you must use Sun Java Studio 11 or higher with -xarch=amd64 flag.
NSAPI plug-ins are typically written using the C programming language. Using the C++ programming language in an NSAPI plug-in raises special compatibility issues.
On Solaris, the server is built using the new C++ 5 ABI. If your shared library uses C++, it must be compiled with Sun Workshop 5.0 or higher. Sun Java Studio 11 or higher is recommended. Do not use the -compat=4 option when compiling and linking a shared library that uses C++. When running in 32–bit mode on Solaris SPARC, the server provides some backward compatibility for the old C++ 4 ABI (Sun Workshop 4.2). This backward compatibility may be removed at some future date. For all new NSAPI plug-ins, use the new C++ 5 ABI (Sun Workshop 5.0 or higher).
On Linux, Web Server is built using the gcc 3.2 C++ ABI. If your shared library uses C++, compile with gcc 3.2.x. Because of the volatility of the gcc C++ ABI, it is advised to avoid using C++ in NSAPI plug-ins on Linux.