EAServer 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++ component library files.
Navigate to the cpplib directory under your EAServer installation, then navigate to the cpptut/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.
cpptut_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 MSVCDIR and ODBCLIB macros:
MSVCDIR=c:\msdev ODBCLIB = "$(MSVCDIR)\lib\odbc32.lib"
If you use the standard Microsoft Visucal C++ setup file, VCVARS32.bat, no changes are needed to these settings. The Visual C++ installation generates VCVARS32.bat to set the MSVCDIR environment variable. If you do not use the generated VCVARS32.bat file, or it is incorrect, edit these lines in the makefile to match your system; set MSVCDIR to the location where Microsoft Visual C++ is installed and set ODBCLIB to the full path to the odbc32.lib file.
Open a command window and change directory to the cpplib/cpptut/CPPArithmetic subdirectory of your EAServer installation. Build the DLL as follows:
Apply the settings in the EAServer djc-setenv.bat file and the Microsoft Visual C++ VCVARS32.bat setup file. For example:
set DJC_HOME=d:\Sybase\EAS60 call %DJC_HOME%\bin\djc-setenv.bat call "D:\engapps\Microsoft Visual Studio\VC98\Bin\VCVARS32.bat"
Run 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.
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.