Compiling a C user-defined extension

Compile user-defined extensions in C for all supported operating systems.

Before you begin

If you create your own user-defined nodes, parsers, and user exits in C, compile them on the operating system on which the target integration node is running. Samples are provided for both nodes and parsers, and are described in Sample node files and Sample parser files. Use the instructions here to compile the samples. If you want to create your own extensions, see the following topics:

About this task

These instructions use the file names of the supplied samples. If you are compiling your own user-defined extensions, substitute your own file names.

When you compile a user-defined extension that is written in C, you need a compatible compiler. For details of supported compilers, see IBM® Integration Bus system requirements.

Header files

About this task

The following header files define the C interfaces:
BipCni.h
Message processing nodes
BipCpi.h
Message parsers
BipCci.h
Interfaces common to both nodes and parsers
BipCos.h
Platform-specific definitions

Compiling

About this task

Compile the source for your user-defined extension on each of the supported operating systems to create the executable file that the integration node calls to implement your user-defined extension. On Linux®, UNIX, and z/OS® systems, this file is a loadable implementation library (LIL) file; on Windows systems, it is a dynamic load library (DLL) file.

The libraries that you build to contain user-defined nodes or parsers must have the extension .lil on all operating systems so that the integration node can load them. Libraries that contain user exits must have the extension .lel on all operating systems. The examples in this topic show libraries with the extension .lil

Refer to the documentation for the compiler that you are using for full details of available compile and link options that might be required for your programs.

Navigate to the directory where your user-defined extension source code is located, and follow the instructions for your operating system:

Compiling on AIX

About this task

When you compile a user-defined extension that is written in C, use a supported compiler.

The following instructions are for compiling an extension for a 64-bit integration server; 32-bit integration servers are not supported.

xlc_r -q64 \
   -I. \
   -I/install_dir/server/include/plugin \
   -c SwitchNode.c \
   -o SwitchNode.o

xlc_r -q64 \
   -I. \
   -I/install_dir/server/include/plugin \
   -c TransformNode.c \
   -o TransformNode.o

xlc_r -q64 \
   -I. \
   -I/install_dir/server/include/plugin \
   -c BipSampPluginUtil.c \
   -o BipSampPluginUtil.o

xlc_r -q64 \
   -I. \
   -I/install_dir/server/include/plugin \
   -c Common.c \
   -o Common.o

xlc_r -q64 \
   -I. \
   -I/install_dir/server/include/plugin \
   -c NodeFactory.c \
   -o NodeFactory.o

xlc_r -q64 \
      -qmkshrobj \
      -bM:SRE \
      -bexpall \
      -bnoentry \
      -o SwitchNode.lil SwitchNode.o \
         BipSampPluginUtil.o Common.o NodeFactory.o \
      -L /install_dir/server/lib \
      -l imbdfplg

chmod a+r SwitchNode.lil

Compiling on HP-Itanium

About this task

When you compile a user-defined extension that is written in C, use a supported compiler.

The following instructions are for compiling an extension for a 64-bit integration server; 32-bit integration servers are not supported.


cc +z +e +DD64 -D_HPUX_SOURCE -DTHREADS -D_REENTRANT -Ae \
   -I. \
   -I/install_dir/server/include \
   -I/install_dir/server/include/plugin \
   -c BipSampPluginUtil.c \
   -o output_dir/BipSampPluginUtil.o

cc +z +e +DD64 -D_HPUX_SOURCE -DTHREADS -D_REENTRANT -Ae \
   -I. \
   -I/install_dir/server/include \
   -I/install_dir/server/include/plugin \
   -c Common.c \
   -o output_dir/Common.o

cc +z +e +DD64 -D_HPUX_SOURCE -DTHREADS -D_REENTRANT -Ae \
   -I. \
   -I/install_dir/server/include \
   -I/install_dir/server/include/plugin \
   -c NodeFactory.c \
   -o output_dir/NodeFactory.o

cc +z +e +DD64 -D_HPUX_SOURCE -DTHREADS -D_REENTRANT -Ae \
   -I. \
   -I/install_dir/server/include \
   -I/install_dir/server/include/plugin \
   -c SwitchNode.c \
   -o output_dir/SwitchNode.o

cc +z +e +DD64 -D_HPUX_SOURCE -DTHREADS -D_REENTRANT -Ae \
   -I. \
   -I/install_dir/server/include \
   -I/install_dir/server/include/plugin \
   -c TransformNode.c \
   -o output_dir/TransformNode.o


ld -b \
   -o output_dir/SwitchNode.lil \
   output_dir/BipSampPluginUtil.o \
   output_dir/Common.o \
   output_dir/NodeFactory.o \
   output_dir/SwitchNode.o \
   output_dir/TransformNode.o \
   -L install_dir/server/lib \
   -L install_dir/xml4c/lib \
   -L install_dir/merant/lib \
   -L install_dir/jre16/lib/IA64N\
   -L install_dir/jre16/lib/IA64N/server \
   -l imbdfplg

chmod a+r output_dir/SwitchNode.lil

Compiling on Linux

About this task

When you compile a user-defined extension that is written in C, use a supported compiler.

When you compile programs on Linux on POWER®, replace the option -fpic with -fPIC if you want to use dynamic linking and avoid any limit on the size of the global offset table.

The following instructions are for compiling an extension for a 64-bit integration server on Linux on x86-64, Linux on POWER, and Linux on Z. 32-bit integration servers are not supported on those platforms. To compile the extension for a 32-bit integration server on Linux on x86, replace -m64 with -m32 in the compile and link examples. To compile the extension for Linux on POWER include the -O2 parameter in the compile and link examples, and include the -fexceptions parameter in the compile examples.

g++ -c -m64 -Wall -Wno-format-y2k -fpic \
   -I. \
   -I/install_dir/server/include \
   -I/install_dir/server/include/plugin \
   -DLINUX -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT \
   TransformNode.c

g++ -c -m64 -Wall -Wno-format-y2k -fpic \
   -I. \
   -I/install_dir/server/include \
   -I/install_dir/server/include/plugin \
   -DLINUX -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT \
   SwitchNode.c 

g++ -c -m64 -Wall -Wno-format-y2k -fpic \
   -I. \
   -I/install_dir/server/include \
   -I/install_dir/server/include/plugin \
   -DLINUX -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT \
   BipSampPluginUtil.c 

g++ -c -m64 -Wall -Wno-format-y2k -fpic \
   -I. \
   -I/install_dir/server/include \
   -I/install_dir/server/include/plugin \
   -DLINUX  -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT \
   Common.c 

g++ -c -m64 -Wall -Wno-format-y2k -fpic \
   -I. \
   -I/install_dir/server/include \
   -I/install_dir/server/include/plugin \
   -DLINUX -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT \
   NodeFactory.c

g++ -m64 -o samples.lil \
   TransformNode.o \
   SwitchNode.o \
   BipSampPluginUtil.o \
   Common.o NodeFactory.o \
   -shared -lc -lnsl -ldl \
   -L/install_dir/server/lib -limbdfplg 

These commands create the file samples.lil that provides TransformNode and SwitchNode objects.

Compiling on Solaris

About this task

When you compile a user-defined extension that is written in C, use a supported compiler.

The following instructions are for compiling an extension for a 64-bit integration server on Solaris on SPARC; 32-bit integration servers are not supported. To compile the extension for a default 64-bit integration server on Solaris on x86-64, replace -xarch=v9 with -xarch=amd64 in the compile examples; 32-bit integration servers are not supported.

cc -xarch=v9 -mt \
   -I. \
   -I/install_dir/server/include \
   -I/install_dir/server/include/plugin \
   -c SwitchNode.c \
   -o output_dir/SwitchNode.o

cc -xarch=v9 -mt \
   -I. \
   -I/install_dir/server/include \
   -I/install_dir/server/include/plugin \
   -c TransformNode.c \
   -o output_dir/TransformNode.o

cc -xarch=v9 -mt \
   -I. \
   -I/install_dir/server/include \
   -I/install_dir/server/include/plugin \
   -c BipSampPluginUtil.c \
   -o output_dir/BipSampPluginUtil.o

cc -xarch=v9 -mt \
   -I. \
   -I/install_dir/server/include \
   -I/install_dir/server/include/plugin \
   -c NodeFactory.c \
   -o output_dir/NodeFactory.o

cc -xarch=v9 -mt \
   -I. \
   -I/install_dir/server/include \
   -I/install_dir/server/include/plugin \
   -c Common.c \
   -o output_dir/Common.o

cc -xarch=v9  -xcode=pic32 -mt -G \
   -o output_dir/SwitchNode.lil \
      output_dir/SwitchNode.o \
      output_dir/BipSampPluginUtil.o \
      output_dir/NodeFactory.o \
      output_dir/Common.o \
   -L /install_dir/server/lib \
   -l imbdfplg

chmod a+r output_dir/SwitchNode.lil

Compiling on Windows

About this task

When you compile a user-defined extension that is written in C, use a supported compiler. If you are using a 64-bit Windows system, you must use the Windows 64-bit linker. By default the 32-bit linker is selected, and the resultant DLL file is not loaded by a 64-bit integration node.

Ensure that you include a space between SwitchNode.c and BipSampPluginUtil.c, and also between -link and /DLL.

Enter the command as a single line of input; in the following example the lines are split to improve readability.

cl /VERBOSE /LD /MD /Zi /EHsc /I. 
   /Iinstall_dir\server\include\plugin 
   SwitchNode.c BipSampPluginUtil.c Common.c 
   NodeFactory.c TransformNode.c 
   -link /DLL install_dir\server\lib\imbdfplg.lib 
   /OUT:SwitchNode.lil

If you have correctly set the LIB environment variable, you do not have to specify the full paths to the LIB files.

Compiling on z/OS

About this task

When you compile a user-defined extension that is written in C, use a supported compiler.

Force your link to use prelinker or linker by setting the _CC_STEPS variable to -1:
export _CC_STEPS=-1
Alternatively, add these two lines to your makefile to export it:
_CC_STEPS=-1
.EXPORT : _CC_STEPS

To create optimized builds, use -2 in place of -g in the following commands:

cc -c \
 -Wc,LP64 -g -W0,langlvl\(extended\),EXPORTALL,float\ieee\) \
 -Wc,xplink \
 -W0,LIST\(./SwitchNode.lst\) \
 -I. -I${install_dir}/server/include \
 -I${install_dir}/server/include/plugin \
 -I${install_dir}/server/sample/include \
 -I${install_dir}/server/sample/plugin \
 -o ./SwitchNode.o ./SwitchNode.c

cc -c \
 -Wc,LP64 -g -W0,langlvl\(extended\),EXPORTALL,float\ieee\) \
 -Wc,xplink \
 -W0,LIST\(./TransformNode.lst\) \
 -I. -I${install_dir}/server/include \
 -I${install_dir}/server/include/plugin \
 -I${install_dir}/server/sample/include \
 -I${install_dir}/server/sample/plugin \
 -o ./SwitchNode.o ./TransformNode.c
cc -c \
 -Wc,LP64 -g -W0,langlvl\(extended\),EXPORTALL,float\ieee\) \
 -Wc,xplink \
 -W0,LIST\(./BipSampPluginUtil.lst\) \
 -I. -I${install_dir}/server/include \
 -I${install_dir}/server/include/plugin \
 -I${install_dir}/server/sample/include \
 -I${install_dir}/server/sample/plugin \
 -o ./BipSampPluginUtil.o ./BipSampPluginUtil.c
cc -c \
 -Wc,LP64 -g -W0,langlvl\(extended\),EXPORTALL,float\ieee\) \
 -Wc,xplink \
 -W0,LIST\(./Common.lst\) \
 -I. -I${install_dir}/server/include \
 -I${install_dir}/server/include/plugin \
 -I${install_dir}/server/sample/include \
 -I${install_dir}/server/sample/plugin \
 -o ./Common.o ./Common.c
cc -c \
  -Wc,LP64 -g -W0,langlvl\(extended\),EXPORTALL,float\ieee\) \
 -Wc,xplink \
 -W0,LIST\(./NodeFactory.lst\) \
 -I. -I${install_dir}/server/include \
 -I${install_dir}/server/include/plugin \
 -I${install_dir}/server/sample/include \
 -I${install_dir}/server/sample/plugin \
 -o ./NodeFactory.o ./NodeFactory.c
cc \
 -Wl,DLL,LP64 -g -Wl,p,map -Wl,LIST=ALL,MAP,XREF,REUS=RENT \
 -Wl,xplink \
 -o ./SwitchNode.lil ./SwitchNode.o ./BipSampPluginUtil.o \
 ./Common.o ./NodeFactory.o \
 ${install_dir}/server/lib/libimbdfplg.x

Run the following command to set the file permissions of the user-defined extension to group read and to be executable:

chmod a+rx {output_dir}/SwitchNode.lil