Chapter 16 Creating CORBA C++ Components
This section describes how to compile and link a component DLL or UNIX shared library that contains Jaguar methods. Your code must be built as a DLL or UNIX shared library in order to be installed into the Jaguar runtime environment. When you generate source files for your component, Jaguar Manager creates an example makefile that builds the component library. You may have to edit this file to match your environment, as described in the following sections:
For components that run on Solaris, you must build shared library (.so) files that contain your C++ component methods.
If your C++ compiler (such as cc on Solaris) does not support namespaces, in the makefile:
CCFLAGS
line:-DJAG_NO_NAMESPACE
LDFLAGS
line:-zmuldefs
After building the shared library, copy it to the cpplib directory of your Jaguar installation.
If you do not place the component shared library in the Jaguar cpplib subdirectory, the directory containing the shared library must be specified in the PATH environment variable.
Jaguar Manager generates a make.unix file when you generate the component skeleton as described in "Generating required C++ files". To build your shared library, run the following command:
make -f make.unix
If you generate stub and skeleton files at the same time,
Jaguar Manager automatically adds the location of the component
stub files to the makefile. If you move the component source files
to another machine, make sure that you copy the stub files as well
and specify their location in the makefile. You specify the component
stub files location by adding /I
stub_location to
the .ccp.obj
rule in the makefile. stub_location is
the directory in which the component stub files reside.
For components that run on Windows NT, you must build a DLL that contains your C++ component methods. After building the DLL, copy it to the cpplib directory of your Jaguar installation.
If you do not place the component DLL in the Jaguar cpplib subdirectory, the directory containing the DLL must be specified in the PATH environment variable.
You can use Jaguar Manager to generate a makefile and module definition (.def) file. See "Generating required C++ files" for instructions on generating a makefile and .def file with Jaguar Manager.
Before compiling your C++ component using nmake with the generated makefile, verify that the makefile can find the directory containing the ODBC header files and libraries. You must set the ODBCHOME environment variable to the directory containing the ODBC header files and libraries. If you have Microsoft Visual C++ and ODBCHOME is not set, the makefile looks in C:\msdev (which is the default installation directory for Microsoft Visual C++) for these files.
If you generate stub and skeleton files at the same time,
Jaguar Manager automatically adds the location of the component
stub files to the makefile. If you move the component source files
to another machine, make sure that you copy the stub files as well
and specify their location in the makefile. You specify the component
stub files location by adding /I
stub_location to
the .ccp.obj
rule in the makefile. stub_location is
the directory in which the component stub files reside.
To build your DLL, run this command from a command window in your component's source directory:
nmake -f make.nt
If you make changes to the makefile, rename it so it won't be overwritten when you regenerate the required files.
Visual C++ requires a module definition file that specifies which functions are exported from a DLL and some options that control how the DLL is loaded into memory. Module definition files end with the extension .def.
For most projects, you can use the generated module definition file as is. In some cases, you may want to edit settings other than those in the EXPORTS section. For example, your component may perform better with a smaller or larger HEAPSIZE setting.
Do not edit the generated function names in the EXPORTS section of the .def file for a C++ component. If you do, the Jaguar dispatcher will not be able to call your methods.
Copyright © 2000 Sybase, Inc. All rights reserved. |