This site hosts historical documentation. Visit www.terracotta.org for recent product information.

BigMemory C++ Client Demo Sample

The following sample is provided in the code-samples/cross-lang/example03/ directory of the kit. The demo is a recipe app that includes ingredients, measurements, and instructions. It uses Google Protocol Buffer serialization and consists of the following files:

  • main.cpp
  • recipe.pb.cc
  • recipe.pb.h
  • RecipeProtoBufSerializer.cpp
  • RecipeProtoBufSerializer.h

To compile and run the demo (Linux):

  1. Install the Cross-Language Connector and customize the cross-lang-config.xml file, as described on the Get Started page.

  2. Start the server as described on the Get Started page.

    Note: If you have already installed the BigMemory Client and Cross-Language Connector, you can run this example by adding the external protobuf dependency. The maven link is

    <dependency>
         <groupId>com.google.protobuf</groupId>
         <artifactId>protobuf-java</artifactId>
         <version>2.5.0</version>
     </dependency>   
    

    This dependency will need to be in both BigMemory Client and CL Connector classpaths. For the CL Connector, the component that needs to be set is EhcacheThriftConfiguration.Builder().cacheSerializerFactory(RecipeSerializerFactory.class) so that the RecipeSerializerFactory, RecipeProtoBufSerializer, and recipe classes will be in the CL Connector's classpath. For the BigMemory Client, the component that will be run is main.cpp, which requires the main, recipe, and RecipeProtoBufSerializer classes to be on the classpath along with the BigMemory Client dependencies.

  3. Run the application. Use G++ to compile and link to platform and serializer libraries. Set the output for console. For example:

    g++ -I<BMKIT>/apis/cpp/include -I<GoogleProtocolBufferInclude> -L<BMKIT>/apis/cpp/<PLATFORM>/<ARCH> -L<GoogleProtocolBufferLib> -lBigMemoryConnector -lprotobuf *.cc *.cpp -o console