Compiling and linking the shared library

After you create your C++ file for your new user-defined shared library, compile the C++ file by using the nzudxcompile command.

About this task

The command is in the /nz/kit/bin/adm directory. The compilation process creates the object files that run on the host and on the Netezza Performance Server SPUs.

You compile and link shared library C++ files to make it usable for the UDXs that reference them. You use the nzudxcompile command to compile and link a shared library for the host environment and on the SPUs.

Note: Unlike other UDXs, you cannot compile and register a shared library in one step with the nzudxcompile command. You must register the library by using CREATE LIBRARY.

To compile and link a shared library named mylib:

Procedure

  1. Create a compiled object for the Netezza Performance Server host environment:
       nzudxcompile /home/nz/libs/mylib.cpp --host
    -o /home/nz/libs/mylib.o
  2. Link the compiled object into a shared library for the host:
       nzudxcompile --objs /home/nz/libs/mylib.o --host -o
    /home/nz/libs/host/mylib.so
  3. Create a compiled object for the Netezza Performance Server SPU environment:
       nzudxcompile /home/nz/libs/mylib.cpp --spu -o
    /home/nz/libs/mylib.o 
    
  4. Link the compiled object into a shared library for the SPU:
       nzudxcompile --objs /home/nz/libs/mylib.o --dynamic --spu
    -o /home/nz/libs/spu/mylib.so
    Note: The --dynamic switch is used only when you are compiling shared libraries for the SPU environment.

Results

The nzudxcompile command creates the following object files:
mylib.o_x86
The object file for the Netezza Performance Server host (i386 Linux® platform on x86).
mylib.o_spu10
The object file for the Linux-based Rev10 SPus on IBM® Netezza® 1000 and Netezza 100 models.

What to do next

After you create the compiled object files, you must register the library with the Netezza Performance Server system so that other UDXs can specify it as a dependency.