Developing C++ Programs on Windows

GemFire uses the Visual Studio 2010 Service Pack 1 compiler for C++ programs on Windows, which invokes Microsoft® cl.exe from the command line at compile time.

The Pivotal GemFire native client 7.0 now supports .NET 4.0 and Visual Studio 2010. For advantages and more information on the features of .NET 4.0 and Visual Studio 2010 SP1, see http://msdn.microsoft.com/en-us/library/dd831853(v=vs.100).aspx and http://msdn.microsoft.com/en-us/library/vstudio/w0x726c2(v=vs.100).aspx.

Visual Studio 2010 SP1 is the recommended compiler. If you are using any other compiler, contact technical support for assistance.

Note: When compiling external projects or applications that are used or referenced by the GemFire native client, make sure that you compile them for the same target architecture as your native client installation. For example, if you installed the 32-bit (x86) version of the native client, compile your external projects for 32-bit (x86) architecture.

Step 1. Installer Sets Up Environment Variables

When you install on Windows, the installer performs these tasks:
  • Sets the GFCPP environment variable to productDir, where productDir is the path to the native client product directory.
  • Adds the %GFCPP%\bin executable directory to the Windows PATH.

Step 2. Choose 32-bit or 64-bit Command-line Prompt

For 32-bit:

Start > Programs > Microsoft Visual Studio 2010 > Visual Studio Tools > Visual Studio 2010 Command Prompt

For 64-bit:

Start > Programs > Microsoft Visual Studio 2010 > Visual Studio Tools > Visual Studio 2010 x64 Win64 Command Prompt

To build using the Microsoft Visual Studio Interface, from the Solutions Platform, choose Win32 or x86 from the Build menu for 32-bit builds or x64 for a 64-bit build.

Step 3. Compile C++ Clients and Dynamically Link Them to GemFire Library

The following table lists the compiler and linker switches that must be present on the cl.exe command line.

Note: If you want to use the Visual Studio user interface instead of invoking cl.exe from the command line, be sure to supply these parameters.
Table 1. Compiler and Linker Switches for Windows
Argument Explanation
/MD Memory model.
/EHsc Catches C++ exceptions only and tells the compiler to assume that *extern* C functions never throw a C++ exception.
/GR Runtime type information.
-I%GFCPP%\include Specifies the GemFire include directory.
%GFCPP%\lib\gfcppcache.lib Specifies the library file for the shared library.
/D_CRT_SECURE_NO_DEPRECATE Suppresses warnings. Required for Visual Studio 2010.
/D_CRT_NON_CONFORMING_SWPRINTFS Suppresses warnings. Required for Visual Studio 2010.

Step 4. Verify that You Can Load the GemFire Library

Because GemFire does not provide a library that can be linked statically into an application on Windows, you must dynamically link to the GemFire library.

To make the GemFire library available for loading, verify that the directory GemFireDir/bin is included in the PATH environment variable, where GemFireDir is the path to the GemFire product directory.