Compiling an In-process Adapter

This section describes the steps required and settings you need to modify in order to compile an in-process adapter.

To compile your in-process adapter, you must specify appropriate settings for your compiler, including:

  1. Specify that the compiler should generate a shared object file (.so) or a dynamic linkable library (.DLL) file.
  2. Your list of "include" directories should contain the directory that holds c8adapter.h.
  3. The list of libraries that you link to should include c8_sdk_server_lib.lib on Microsoft Windows or c8_sdk_server_lib.so on UNIX-like operating systems.

    If you are on Microsoft Windows, you can use Microsoft's Visual Studio. If you are using Visual Studio, perform the following actions to compile your in-process adapter:

  4. Start Microsoft Visual Studio.
  5. Create a project file by going to the menu and clicking on File -> New -> Project.
    1. Click on the [+] to expand "Visual C++ Projects".
    2. Click on "Win32".
    3. In the right-hand pane, Click on "Win32 Project".
    4. Fill in the name that you want to use for your project.
    5. Browse and specify the directory in which you want the project to be stored.
    6. Click "OK".
    7. When the "Win32 Application Wizard" window appears,click on "Application Settings", then click on "DLL".
    8. Click on "Finish".
  6. Microsoft Visual Studio creates a simple .cpp file to use as a starting point. We recommend removing all contents of this file and inserting your own C code for the in-process adapter. Make sure that your code contains "#includes" and forward declarations described in the section titled Requirements for the C/C++ File.
  7. If you have other C-language source files that you need, add them to the project
  8. Update several settings that are available in the "Property Pages" for this project.
    1. Update the list of directories to search for include files.

      To do this, go to the menu, click on "Project" and then on "MySample Properties".

      You will get a new window titled "MySample Property Pages". In the left-hand pane of this window, click on "Configuration Properties", then on "", and then on "General".

      The right-hand pane should now show a list of settings that you can modify. Click in the field to the right of "Additional Include Directories" and add the directory that contains the c8adapters.h file which is included with the Sybase CEP product.

      On Microsoft Windows, this directory is typically:

      C:\Program Files\SybaseC8\Server\sdk\c\include
      

      On64-bit Microsoft Windows, this directory is typically:

      C:\Program Files (x86)\SybaseC8\Server\sdk\c\include
      

      You can add other directories if necessary for your in-process adapter.

    2. Turn off precompiled headers. To do this, go to the left-hand pane in the "Property Pages" window, click on "" and then on "Precompiled headers", then click on "Create/Use Precompiled Header" and set it to "Not Using Precompiled Headers".
    3. Add the Sybase CEP library files. To do this, go to the left-hand pane of the "Property Pages" window, click on "Linker" and then on "General".

      In the field to the right of "Additional Library Directories", add the directory that contains the library.

      On 32-bit Microsoft Windows, this directory is typically:

      C:\Program Files\SybaseC8\Server\sdk\c\lib
      

      On Microsoft Windows, this directory is typically:

      C:\Program Files (x86)\SybaseC8\Server\sdk\c\lib
      
    4. Tell the linker not to include debugging information. To do this, go to the left-hand pane of the "Property Pages" window, click on "Linker" and then on "Debugging". For the field "Generate Debugging Info", change the value to "No".
    5. Add a dependency on the c8_sdk_server_lib.lib file. To do this, go to the left-hand pane of the "Property Pages" window, click on "Linker" and then on "Input".

      In the field to the right of "Additional Dependencies", enter

      c8_sdk_server_lib.lib
      

      (Note that you do not need to enter the complete path; entering the file name is sufficient.)

      If you are using Microsoft's Visual C development and environment and you'd like to double check that you haven't skipped a step, you can look at the "Command Line" for the C/C++ compiler and the "Command Line" for the Linker.

      To view the command line for the compiler, go to the left-hand pane of the Property Pages window, click on "C/C++" and then click on "Command Line". The command line should look similar to the following:

      
      /Od /I "C:\Program Files\SybaseC8\Server\sdk\c\include" 
        /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" 
        /D "INPROCESSOUTPUTADAPTER4_EXPORTS" /D "_WINDLL" 
        /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd 
        /Fo"Debug\\" /Fd"Debug\vc80.pdb" /W4 /nologo /c 
        /Wp64 /ZI /TP /errorReport:prompt
      

      If you set the warning level to a value other than 3, then the "/W3" will be different.

      The command line can or can not include

      
      /D "_DEBUG"
      

      If the command line includes this, you can only be able to use the .DLL on a computer that has the debug version of the C runtime library. (For more information, see the Troubleshooting section.)

      To view the command line for the linker, go to the left-hand pane of the Property Pages window, click on "Linker" and then click on "Command Line". The command line should look like the following:

      
      /OUT:"C:\c8test\E2\C_SDK\Adapter4\Adapter4\Debug\Adapter4.dll" 
        /INCREMENTAL /NOLOGO /LIBPATH:"C:\Program Files\SybaseC8\Server\sdk\c\lib" 
        /DLL /MANIFEST /MANIFESTFILE:"Debug\Adapter4.dll.intermediate.manifest" 
        /SUBSYSTEM:WINDOWS /MACHINE:X86 /ERRORREPORT:PROMPT c8_sdk_server_lib.lib 
        kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib 
        shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
      

      Now that you have entered all the project properties, click the "OK" button on the "Property Pages" window. At this point you should be ready to compile.

  9. To compile, use the appropriate option on the "Build" menu (for example, "Build MySample").
  10. Copy the DLL file to the server's "bin" directory.
  11. If you are using a command-line compiler (such as "cc"), please perform the following steps:
    1. Create and execute a script file with commands similar to the following. The example below is based on the "cc" compiler found on many UNIX-like operating systems:
        cc  -I${HOME}/sybasec8/server/sdk/c/include  \
            -o libmma.so  \
            -L${HOME}/sybasec8/server/sdk/c/lib/  \
            -lc8_sdk_server_lib  \
            -fPIC  \
            -shared  \
            mma.c
      

      where "mma.c" is the name of your source code file and "libmma.so" is the name you want to use for the library file.

      • I specifies the directory(s) to be searched for "#include" files.
      • o specifies the name of the output file or the shard library file.
      • L specifies the directory(s) to search for library files that need to be linked with this one.
      • l specifies the name of the Sybase CEP library to link with in order to use Sybase CEP functions such as C8GetFloat()
      • shared specifies that the output will be a shard object lirary file as opposed to, for example, a stand-alone executable program.
      Warning!  Although on UNIX-like operating systems your library file name is typically of the form "libXYZ.so" (for example, "libmma.so"), your .adl file should specify only "mma" as the library name. Do not specify "libmma.so" in the .adl file. The .adl file "interpreter" makes platform-specific adjustments for the filename extension (.so vs. .dll) and, if necessary, an initial "lib" prefix.
    1. Copy the compiled shared library file to the server's "bin" directory.
      Copy the .adl file to both the server's plugins directory and the Studio's plugins directory.
  12. Copy the compiled shared library file to the server's "bin" directory.
  13. Copy the .adl file to both the server's plugins directory and Studio's plugins directory.

    Alternatively, use a makefile or other technique to compile the file.