Contents
Building StreamBase C++ functions for 64-bit Windows requires the following setup:
-
You must use Visual C++ 8.0 (Visual Studio 2005) to build the DLL that contains your functions. This constraint is defined by 64-bit Oracle Java 6 for Windows, which uses Visual C++ 8.0 internally.
-
You must configure your Visual C++ projects as described on this page.
-
The machine hosting Visual C++ 8.0 must have a 64-bit installation of StreamBase.
-
In general, these requirements mean you must be working on a supported 64-bit edition of Windows.
Alternate Project Types
-
To build C++ functions for 32-bit Windows, you must use Visual C++ 7.1 and must configure your projects as described in Configure VC 7.1 for Functions.
-
To build C++ clients for 32-bit or 64-bit Windows using Visual C++ 8.0, configure your projects as described in Configure Visual Studio 8.0 Projects to Build Clients.
StreamBase does not provide a Debug version of the library files for StreamBase Server, and thus does not support building Debug versions of DLLs that contain custom functions. The instructions on this page describe the configuration to build a Release version of your DLLs. If you need to debug your function's code, you must arrange to do so independent of the StreamBase framework.
To configure Visual C++ 8.0 projects to build 32-bit custom C++ functions, you can either:
-
Copy the
folder to your Visual C++ workspace. You must copy the folder from a 64-bit installation of StreamBase.streambase-install-dir\sample\custom-simple-functionFor clarity, keep your Visual C++ workspace in a separate location from your StreamBase Studio workspace.
Note
You must copy this folder from the StreamBase installation directory. Do not make a copy of the
custom-simple-functionsample in your StreamBase Studio workspace, because the Studio workspace sample does not have the Visual Studio.slnand.vcprojfiles.If you are creating a custom aggregate function, copy the following folder instead:
streambase-install-dir\sample\custom-aggregate-function -
Locate the
custom-simple-function-x64.slnfile. You can optionally rename this file before opening it the first time. Preserve the.slnextension, and choose a basename that reflects the purpose of the intended client. For example, renamecustom-simple-function-x64.slntowicked-cool-function-x64.sln. -
Start Visual C++ 8.0. Use → → to load
custom-simple-function-x64.sln(or your renamed solution file,wicked-cool-function-x64.sln). Let the conversion wizard update the solution file. -
In the Solution Explorer, rename the
logfunctionproject as appropriate for your custom function. For example, rename it towicked-cool. -
Rename
LogFunction.cppas appropriate for your function. For example, rename it towicked.cpp. -
In the Solution Explorer, right-click your project and select Properties from the context menu.
-
Notice that the Configuration drop-down menu contains only Release and Active (Release), and does not have an All Configurations option. This is because the
custom-simple-function-x64.slnsample is configured to build only a 64-bit DLL, and because you cannot build a Debug version of your DLL, as described above.Accordingly, on the Configuration drop-down menu, choose either Release or Active (Release), which are effectively the same configuration:
-
In the → properties, optionally rename the DLL file to be generated from
log-x64.dllto the filename of your choice, such aswickedcool-x64.dll:Property Folder Property Page Property Row Setting Linker General Output File $(OutDir)\my-dll-name.dll -
Locate the places in the project properties that use
${STREAMBASE_HOME}and replace those with the absolute path to your top-level StreamBase installation directory. In general, do this by clicking in the specified setting row, then click the button with three dots to open the Additional Directories dialog. Select a row in this dialog and use the second three-dot button to navigate to your StreamBase installation's directory:-
Confirm the following setting:
Property Folder Property Page Property Row Setting C/C++ General Additional Include Directories Replace the path that uses ${STREAMBASE_HOME}with the absolute path to theincludedirectory of your StreamBase installation:streambase-install-dir\include -
Confirm the following setting:
Property Folder Property Page Property Row Setting Linker General Additional Library Directories Replace the path that uses ${STREAMBASE_HOME}with the absolute path to thelib64\Releasedirectory of your StreamBase installation:streambase-install-dir\lib64\Release
-
-
Make sure the Solution Configuration drop-down is set to Release and the Solution Platform drop-down is set to x64, then build your project. Verify that a DLL of the specified name is generated in the
x64\Releasefolder. -
Begin customizing the source file for your client.
-
When you have a DLL ready to test in the context of a StreamBase application, follow the steps in Deploying Custom C++ Functions.
To create a new Visual C++ project from scratch, select → → . In the New Project dialog, select → , then select MFC DLL.
Whether using an existing Visual C++ project or starting with a new one, make sure the project's settings match those described in the following steps. All project settings not listed here are optional, and can be changed to match the requirements of your project.
-
In Visual C++ Studio, select → → .
-
In the New Project dialog, select → , then select Win32 Console Application.
-
In the Name field, enter a name for your project.
-
In the Win32 Application Wizard dialog, select Application Settings.
-
Under Application Type, select DLL.
-
If you already have a C++ file that contains your function, then under Additional options, select Empty project. If you are starting from scratch, leave this check box cleared.
-
Click .
-
-
If you already have a C++ file for your function, use Windows Explorer to drag that file to the newly created project folder.
-
Back in Visual C++ Studio, in the Solution Explorer panel, right-click the new project and select from the context menu.
-
In the project's Property Pages dialog, click the Configuration Manager button.
-
In the Configuration Manager dialog, select the row for your new project.
-
In the Release column, click the drop-down arrow and select <Edit>.
-
In the Edit Project Configurations dialog, remove the Debug option and close the dialog.
-
In the Platform column, click the drop-down arrow and select <New>.
-
In the New Project Platform dialog, select x64 from the first drop-down menu, then close the dialog.
-
In the Platform column, click the drop-down arrow and select <Edit>.
-
In the Edit Project Platforms dialog, remove the Win32 option and close the dialog.
-
Close the Configuration Manager dialog.
You can now select only Release and x64 from the Configuration and Platform drop-down menus.
-
-
Make sure the following settings are in place:
Property Folder Property Page Property Row Setting Configuration Properties General Configuration Type From the drop-down menu, select Dynamic Library (.dll). Configuration Properties General Use of MFC From the drop-down menu, select Use Standard Windows Libraries. Configuration Properties General Use Managed Extensions No C/C++ General Additional Include Directories Path to the includedirectory of your StreamBase installation.streambase-install-dir\includeDo not use the environment variable
STREAMBASE_HOMEto define this path (unless you have applied this variable globally as described in StreamBase Command Prompt). If there is already an entry in this row that uses${STREAMBASE_HOME}, replace that entry.Instead, click in the row and use the button with three dots on the right side to open the Additional Include Directories dialog. Select a row in this dialog and use the second three-dot button to navigate to your StreamBase installation's
includedirectory.C/C++ Preprocessor Preprocessor Definitions Append the following definition to the default list: STREAMBASE_PTHREAD_DLLC/C++ Code Generation Runtime Library From the drop-down menu, select . C/C++ Precompiled Headers Create/Use Precompiled Headers From the drop-down menu, select Not Using Precompiled Headers. Linker General Additional Library Directories Append the following path to the entries in that row: streambase-install-dir\lib64\ReleaseAs described above, do not use
STREAMBASE_HOMEto define this path.Linker Input Additional Dependencies Fill in the Additional Dependencies row with the following entries:
LibsbClient-vc8.lib
sbserver.lib
pthreads-vc8.lib
WS2_32.lib
xercesLib-vc8.lib
Dbghelp.libIn the Additional Dependencies dialog, make sure the Inherit from project defaults check box is selected.
-
Begin customizing the source file for your client.
-
When you have a DLL ready to test in the context of a StreamBase application, follow the steps in the next section.
To deploy your custom functions in the context of your StreamBase application, follow these steps:
-
Copy the DLL file generated in the steps above to the root of your StreamBase Studio project folder.
-
Edit your server configuration file to reference the new function:
-
Reference the DLL file name in
pluginchild element of theglobalelement. For example:<global> <plugin file="./wicked-cool.dll" /> </global>
See the
globalsection of the StreamBase Server Configuration File XML Reference for details. -
Declare the function in a
custom-functionelement as described in thecustom-functionssection of the StreamBase Server Configuration File XML Reference.
-
-
Make sure you have referenced your custom function's name with consistent spelling and capitalization in the following places:
-
The required C++ macro in the C++ file that defines your function. For example:
STREAMBASE_DEFINE_PLUGIN_FUNCTION(LogFunction, "log");
-
The
custom-functionelement of the server configuration file. For example:<custom-function name="log" type="simple" > <args> ...
-
In the expression in an EventFlow or StreamSQL module that calls your function. For example:
callcpp("log", 1, 3)
-
Your DLL can contain multiple custom functions, following these rules:
-
Add multiple C++ files to the Visual C++ project that generates the same DLL, with one function per C++ file.
-
For each function defined in the DLL, provide a separate
custom-functionelement in the server configuration file.
