EAServer Manager has generated C++ implementation templates for the component methods. Here we will fill in the implementation template, then build a shared library or DLL file. Finally, we will verify that the shared library or DLL is in the EAServer cpplib subdirectory, where EAServer expects to find C and C++ component library files.
Writing the server-side code
Navigate to the cpplib directory under your EAServer installation, then navigate to the Tutorial/CPPArithmetic subdirectory. You should see the following files:
CPPArithmeticImpl.hpp.new Template for the component header file. Defines the CPPArithmeticImpl class. No changes are required for the tutorial, other than renaming the file as discussed below.
CPPArithmeticImpl.cpp.new Template for the component implementation. Contains the definition of the component methods. Changes you must make to this file are described below.
Tutorial_CPPArithmetic.cpp Source for the skeleton. Do not modify the generated skeleton code.
make.nt Microsoft nmake makefile. The nmake utility is included with the Microsoft Visual C++ installation.
Rename the implementation files to CPPArithmeticImpl.hpp and CPPArithmeticImpl.cpp. (In other words, remove the .new extension from both file names).
Open CPPArithmeticImpl.cpp in a text editor, then find the definition of the multiply method. Change the definition so that it matches the one below:
CORBA::Double CPPArithmeticImpl::multiply (CORBA::Double m1, CORBA::Double m2) { CORBA::Double result; result = m1 * m2; return result; }
Save your changes.
Building the component on Windows
Verify your setup as described in “Verify your environment”.
Rename make.nt to Makefile, then open Makefile in a text editor. Find the definition of the ODBCHOME macro:
ODBCHOME=d:\msdev
Change the ODBCHOME definition to match the directory where you have installed Microsoft Visual C++, for example:
ODBCHOME="D:\engapps\devStudio\VC98"
Save your changes.
Build the DLL by running nmake (no arguments are required).
You should see a new file called libCPPArithmetic.dll. Verify that the makefile has copied this file to the EAServer cpplib subdirectory. If nmake fails, verify that you have renamed the .cpp and .hpp implementation files with the expected file names, and that you have applied the correct edits to CPPArithmeticImpl.cpp and Makefile.
Building the component on UNIX platforms
Verify your setup as described in “Verify your environment”.
Rename make.unix to Makefile.
On Solaris, the make file is compatible with the Solaris
CC compiler, version 6.x. If you use a version
4.x compiler, edit Makefile and
change -L$JAGUAR/lib
to -L$JAGUAR/lib_sol4x
.
You must use the compiler version that is compatible with your server.
The default server binary requires libraries compatible with the
6.x compiler, but you can override this setting
when starting the server. For more information, see “Starting the
server” in the EAServer System Administration
Guide.
Build the shared library by running make (no arguments are required).
You should see a new file called libCPPArithmetic.ext, where ext is the appropriate shared library extension for your platform. Verify that the makefile has copied this file to the EAServer cpplib subdirectory.
If make fails, verify the following:
You have renamed the .cpp and .hpp implementation files with the expected file names, and that you have applied the correct edits to CPPArithmeticImpl.cpp.
The compile and link settings in Makefile are
appropriate for your installation. The settings are defined in the
file cpplib/make.include.plat, where plat is
the platform code returned by running uname -s
on
your system. If necessary, edit this file to match your system configuration.
Copyright © 2005. Sybase Inc. All rights reserved. |