Write the server-side code

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.

StepsWriting the server-side code

  1. Navigate to the cpplib directory under your EAServer installation, then navigate to the cpptut/CPPArithmetic subdirectory. You should see the following files:

  2. Rename the implementation files to CPPArithmeticImpl.hpp and CPPArithmeticImpl.cpp. (In other words, remove the .new extension from both file names).

  3. 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;
    }
    
  4. Save your changes.

StepsBuilding the component on Windows

  1. Verify your setup as described in “Verify your environment”.

  2. 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.

  3. Open a command window and change directory to the cpplib/cpptut/CPPArithmetic subdirectory of your EAServer installation. Build the DLL as follows:

    1. 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"
      
    2. 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.

StepsBuilding the component on UNIX platforms

  1. Verify your setup as described in “Verify your environment”.

  2. Rename make.unix to Makefile.

  3. 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: