User Guide

Table Of Contents
Developing CFX tags in C++ 269
Developing CFX tags in C++
The following sections provide information to help you develop CFX tags in C++.
Sample C++ CFX tags
Before you begin development of a CFX tag in C++, you might want to study the two CFX tags
included with ColdFusion MX. These examples will help you get started working with the
CFXAPI. The two example tags are as follows:
CFX_DIRECTORYLIST Queries a directory for the list of files it contains.
CFX_NTUSERDB (Windows only) Lets you add and delete Windows NT users.
On Windows, these tags are located in the cf_root\cfx\examples directory. On UNIX, these tags
are in the cf_root/coldfusion/cfx/examples directory.
Setting up your C++ development environment
The following compliers generate valid CFX code for UNIX platforms:
Before you can use your C++ compiler to build custom tags, you must enable the compiler to
locate the CFX API header file, cfx.h. In Windows, you do this by adding the CFX API include
directory to your list of global include paths. In Windows, this directory is cf_root\cfx\include.
On UNIX this directory is cf_root/cfx/include. On UNIX, you will need
-I <includepath> on
your compile line (see the Makefile for the directory list example in the cfx/examples directory).
Compiling C++ CFX tags
CFX tags built in Windows and on UNIX must be thread-safe. Compile CFX tags for Solaris
with the
-mt switch on the Sun compiler.
Locating your C++ library files on UNIX
On UNIX systems, your C++ library files can be in any directory as long as the directory is
included in LD_LIBRARY_PATH or SHLIB_PATH (HP-UX only).
Implementing C++ CFX tags
CFX tags built in C++ use the tag request object, represented by the C++
CCFXRequest class.
This object represents a request made from an application page to a custom tag. A pointer to an
instance of a request object is passed to the main procedure of a custom tag. The methods
available from the request object let the custom tag accomplish its work. For information about
the CFX API classes and members, see Chapter 7, “ColdFusion C++ CFX Reference” in CFML
Reference.
Note: Calling a non-existent C++ CFX procedure or entry point causes a JVM crash on UNIX.
Platform Compiler
Solaris Sun C++ compiler 5.0 or higher (gcc does not work)
Linux RedHat 6.2 gcc/egcs 1.1.2 compiler