Write C components  Debug C components

Appendix C: Creating C Components

Compile C components

This section describes how to compile and link a dynamic link library (DLL) that contains EAServer methods. Your code must be built as a DLL 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:


Build on UNIX

For servers that run on UNIX, you must build shared library files that contain your C component methods. After building the shared library, copy it to the cpplib directory of your EAServer installation.

EAServer Manager generates a make.unix file when you generate the component skeleton. (See “Generate C component files” for instructions on generating code with EAServer Manager.)

To build your component, run the following command:

make -f make.unix 

This command builds a shared library named libComp.so, where Comp is the EAServer Manager name of the component.

NoteIf you edit the generated make.unix file, rename the edited version so that it is not overwritten if you regenerate the skeleton files.


Build on Windows

For servers that run on Windows, you must build dynamic link library (.dll) files that contain your C component methods.

Follow the instructions in the sections below to build a DLL. After building the shared library, copy it to the cpplib directory of your EAServer installation.


DLLs for C components

For Windows, you must build a DLL so that C functions use the standard C calling function.

EAServer Manager generates a make.nt file when you generate the component skeleton. (See “Generate C component files” for instructions on generating code with EAServer Manager.)

The generated makefile assumes that the ODBC header files and libraries can be found in one of the following locations:

The makefile links the following import libraries:

If your code calls routines defined in other import libraries, you will need to rename and edit the generated makefile to use the additional import libraries. If you edit the generated make.nt file, rename the edited version so that it is not overwritten if you regenerate the skeleton files.To use the generated makefile, run this command from a command window while in your component’s source directory:

nmake -f make.nt

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


Build with the Visual C++ IDE

If you use the Visual C++ IDE or another command line compiler to build your DLL, make sure that you specify the right options so that the compiler generates C functions using the standard C calling convention.

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


The module definition (.def) file

EAServer Manager generates a .def file for your component. 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 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.

Never edit the generated function names in the EXPORTS section of the .def file for a C component–these names are required to execute the DLL in EAServer. For each method in your component, the changed name is:

__skl_Comp_v_1_0_method




Copyright © 2005. Sybase Inc. All rights reserved. Debug C components