Compile and Link Source Code to Build Dynamically Linkable Libraries

Use compile and link switches when building dynamically linkable libraries for any user-defined function.

  1. A UDF dynamically linkable library must include an implementation of the function extfn_use_new_api(). The source code for this function is in Setting the dynamic library interface. This function informs the server of the API style that all functions in the library adhere to. The sample source file my_main.cxx contains this function; you can use it without modification.

  2. A UDF dynamically linkable library must also contain object code for at least one UDF function. A UDF dynamically linkable library may optionally contain multiple UDFs.

  3. Link together the object code for each UDF as well as the extfn_use_new_api() to form a single library.

    For example, to build the library "libudfex:"
    • Compile each source file to produce an object file:

      my_main.cxx 
      my_bit_or.cxx 
      my_bit_xor.cxx 
      my_interpolate.cxx 
      my_plus.cxx 
      my_plus_counter.cxx 
      my_sum.cxx
      my_byte_length.cxx
      my_md5.cxx
      my_toupper.cxx
      tpf_agg.cxx
      tpf_blob.cxx
      tpf_dt.cxx
      tpf_filt.cxx
      tpf_oby.cxx
      tpf_pby.cxx
      tpf_rg_1.cxx
      tpf_rg_2.cxx
      udf_blob.cxx
      udf_main.cxx
      udf_rg_1.cxx
      udf_rg_2.cxx
      udf_rg_3.cxx
      udf_utils.cxx
    • Link together each object produced into a single library.

    After the dynamically linkable library has been compiled and linked, complete one of these tasks:
    • (Recommended) update the CREATE FUNCTION ... EXTERNAL NAME or CREATE PROCEDURE ... EXTERNAL NAME to include an explicit path name for the UDF library.
    • Place the UDF library file into the directory where all the Sybase IQ libraries are stored.
    • Start the server with a library load path that includes the location of the UDF library.

      On UNIX modify the LD_LIBRARY_PATH within the start_iq startup script. While LD_LIBRARY_PATH is universal to all UNIX variants, SHLIB_PATH is preferred on HP, and LIB_PATH is preferred on AIX.

      On UNIX platforms, the external name specification can contain a fully qualified name, in which case the LD_LIBRARY_PATH is not used. On the Windows platform, a fully qualified name cannot be used and the library search path is defined by the PATH environment variable.

  4. Run iqdir15/samples/udf/build.bat on Windows. Run iqdir15/samples/udf/build.sh on UNIX.