Compiling an RPC Plugin for Windows

This section explains the process of compiling an RPC plugin for a Windows platform.

If you are on Microsoft Windows and are using Microsoft's Visual Studio, please do the following:

  1. Start Microsoft Visual Studio.
  2. Create a project file by going to the menu and clicking on File -> New -> Project.
    1. Specify that this is a Visual C++ Project.
    2. Click on "Win32".
    3. In the right-hand pane, Click on "Win32 Project".
    4. Fill in the name that you'd like to use for your project.
    5. Browse and specify the directory in that you want the project to be stored.
    6. Click OK.
    7. The next window to appear will be the "Win32 Application Wizard" window. On the left, click on "Application Settings", then click on "DLL".
    8. Click on "Finish".
  3. Microsoft Visual Studio creates a simple .cpp file to use as a starting point. We recommend that you remove all the contents of this file and insert the C code for the RPC plugin. Make sure that the source code file includes code similar to the following:
    #include "c8rpc.h"
    	#include "c8_http_client.h"
    	// exporting stuff from dll
    	#if defined(_MSC_VER)
    	#define USER_ADAPTER_EXPORT __declspec( dllexport )
    	#else // defined(_MSC_VER)
    	#define USER_ADAPTER_EXPORT 
    	#endif // defined(_MSC_VER)
    	// forward declarationsof RPC plugin callback functions 
    	#ifdef __cplusplus
    	extern "C" {
    	#endif /* __cplusplus */
    	USER_ADAPTER_EXPORT 
    	C8Status 
    c8_rpc_http_initialize
    (C8Rpc * rpc_ctx);
    	USER_ADAPTER_EXPORT 
    	C8Status 
    c8_rpc_http_execute
        (C8Rpc * rpc_ctx, 
                                const C8Message *);
    	USER_ADAPTER_EXPORT 
    	void 
       c8_rpc_http_shutdown
       (C8Rpc * rpc_ctx);
    	#ifdef __cplusplus
    	} /* extern "C" */
    	#endif /* __cplusplus */
    

    You can customize the names shown in bold but the names used in the source code file and the names used in the c8-services.xml file must match.

  4. If you have other C-language source files that you need, add them to the project.
  5. 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 "Properties". You should get a new window titled something like "MySample Property Pages".

      In the left-hand pane of this window, click on "Configuration Properties", then on "C/C++", and then on "General".

      The right-hand pane should now show a list of settings that you may modify.

      Click in the field to the right of Additional Include Directories and add the directory that contains the files c8rpc.h and c8_client_http.h (which are included with the Sybase CEP product).

      On 32-bit Microsoft Windows, this directory containing c8rpc.h is typically:

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

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

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

      The directory containing c8_http_client.h depends upon where you've copied this file to.

      You can also add other directories if necessary.

    2. Turn off precompiled headers.

      To do this, go to the left-hand pane in the Property Pages window, click on "C/C++" 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 directory to the list of library directories. 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 Sybase CEP library.

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

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

      On 64-bit 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 nspr4.lib plc4.lib libxml2.lib

      You do not need to enter the complete path; entering the file name is sufficient.)

      If 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 for the Linker. These show the command-line parameters passed from Microsoft's GUI IDE to the command-line compiler and linker.

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

      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.

  6. To compile, use the appropriate option on the Build menu, for example, "Build MySampleRPC".
  7. Copy the DLL file to the server's bin directory. In Microsoft Windows, this directory defaults to:

    C:\Program Files\SybaseC8\Server\bin