After writing a user-defined program, use the rtlink
shell script to link it with the necessary TIBCO SmartSockets libraries. These sections present some examples of using the rtlink
script to link the program stored in the myprog.c
and extfunc.c
files.
Here are examples of two methods of invoking the rtlink
script on UNIX. In one example, the compiling and linking steps are executed separately; in the other, they are combined into one step. Both examples use the -o
flag to explicitly name the executable, and the -O
flag to enable compiler and SmartSockets optimization. By default, rtlink
uses the cc
command to compile and link, but you can override this by using the CC
environment variable. For more information on compiling and linking, see the section on rtlink
in TIBCO SmartSockets Utilities.
/* Separate compiles followed by a separate link */
$ cc -O -I$RTHOME/include/$RTARCH -c myprog.c $ cc -O -I$RTHOME/include/$RTARCH -c extfunc.c $ rtlink -O myprog.o extfunc.o -o myprog.x/* Combined compiles and link */
$ rtlink -O myprog.c extfunc.c -o myprog.x
By default, rtlink
uses the cc
command to compile and link files. If the CC
environment variable is set, rtlink
instead uses the CC
environment variable to determine the command to invoke. To use a different compiler, set this environment variable to the compiler you wish to use. Here is an example using a C++ compiler:
If you are using the make
utility to control and execute your compilations, you can instead set the CC
variable in your makefile
and make
will automatically set the CC
environment variable each time it runs a command. Here is an example of setting CC
from a makefile
to use the GNU C compiler:
CC = gcc CFLAGS = -O -I$(RTHOME)/include/$(RTARCH) OBJECTS = myprog.o extfunc.o myprog.x: $(OBJECTS) rtlink $(OBJECTS) -o $@
If you are using GNU make
, this may be needed instead in your makefile
or GNUmakefile
:
export CC = gcc CFLAGS = -O -I$(RTHOME)/include/$(RTARCH) OBJECTS = myprog.o extfunc.o myprog.x: $(OBJECTS) rtlink $(OBJECTS) -o $@
On OpenVMS, the rtlink
syntax is similar to that for UNIX, except that it is not possible to combine the compilation and link steps. These steps must be explicitly invoked. This example uses the /executable
qualifier to explicitly name the executable. For more information on compiling and linking, see the section on rtlink
in TIBCO SmartSockets Utilities.
/* Separate compiles followed by a separate link */
$ cc/optimize myprog.c
$ cc/optimize extfunc.c
$ rtlink/executable=myprog.exe myprog.obj extfunc.obj
The compilations create object files named myprog.obj
and extfunc.obj. rtlink
creates an executable named myprog.exe
.
On Windows, compiling and linking is usually done in the Visual C++ Developer Studio environment. There is no rtlink
script on Windows. You can use one of several example Visual C++ makefiles in %RTHOME%\examples\smrtsock\manual
as a starting point for your application executables.
Under Windows, if you are using SmartSockets for the first time, you need to set the paths for your include files and libraries in Developer Studio. You must also set the Project settings in Developer Studio. See the TIBCO SmartSockets Installation Guide for details on this.
TIBCO SmartSockets™ Application Programming Interface Software Release 6.8, July 2006 Copyright © TIBCO Software Inc. All rights reserved www.tibco.com |