Writing the class implementation  Debugging C++ components

Chapter 14: Creating CORBA C++ Components

Compiling source files

This section describes how to compile and link a component DLL or UNIX shared library that contains EAServer methods. Your code must be built as a DLL or UNIX shared library in order to be installed into the EAServer runtime environment. When you generate source files for your component, EAServer 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:


Compiling on UNIX platforms

EAServer 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 

On Solaris, when linking component shared libraries or client binaries, you must link with the EAServer libraries that match your compiler version. Choose the appropriate directory from those listed below:

The generated Solaris make files link with 6.x libraries by default. To use 4.x libraries, edit the definition of the LIB macro in the make file, and change the paths to the library directories. The library and binary format is different between version 6.x and version 4.x compilers. Use the compiler version that the server is running with. By default, the server runs with version 6.x compatibility, but you can override this when starting the server. For more information, see “Starting the server” in the EAServer System Administration Guide.

The generated UNIX make file for C++ components works on other platforms without changes. Platform-specific information is defined in the file make.include.platform, where platform is the name returned by the command:

uname -s

The make.include.platform includes the necessary settigngs to run the compiler and linker in the component make file. You may need to edit these settings if your compiler and linker are not installed in the standard location, or you use different software.

If you generate stub and skeleton files at the same time, EAServer 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 /Istub_location to the .ccp.obj rule in the makefile. stub_location is the directory in which the component stub files reside.

After building the shared library, copy it to the cpplib directory of your EAServer installation.

NoteIf you do not place the component shared library in the EAServer cpplib subdirectory, the directory containing the shared library must be specified in the shared library search path environment variable for your platform (for example, LD_LIBRARY_PATH for Solaris).


Compiling on Windows

For components that run on Windows, you must build a DLL that contains your C++ component methods. After building the DLL, copy it to the cpplib directory of your EAServer installation.

NoteIf you do not place the component DLL in the EAServer cpplib subdirectory, the directory containing the DLL must be specified in the PATH environment variable.

You can use EAServer 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 EAServer 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, EAServer 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 /Istub_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++

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.

NoteDo not edit the generated function names in the EXPORTS section of the .def file for a C++ component. If you do, the EAServer dispatcher will not be able to call your methods.





Copyright © 2005. Sybase Inc. All rights reserved. Debugging C++ components