6 Setting Up C++ Application Builds

This chapter provides instructions for setting up C++ application builds to use Coherence for C++.

The following sections are included in this chapter:

6.1 Setting up the Compiler for Coherence-Based Applications

When integrating Coherence for C++ into your application's build process, it is important that certain compiler and linker settings be enabled. Some settings are optional, but still highly recommended.

*MSVC (Visual Studio)*

Table 6-1 Compiler Settings for MSVC (Visual Studio)

Setting Build Type Required? Description

/EHsc

All

Yes

Enables C++ exception support

/GR

All

Yes

Enables C++ RTTI

/O2

Release

No

Enables speed optimizations

/MD

Release

Yes

Link against multi-threaded DLLs

/MDd

Debug

Yes

Link against multi-threaded debug DLLs


g++ / SunPro

Table 6-2 Compiler Settings for g++

Setting Build Type Required Description

-O3

Release

No

Enables speed optimizations

-m32 / -m64

All

No

Explicitly set compiler to 32 or 64 bit mode


6.2 Including Coherence Header Files

Coherence ships with a set of header files that uses the Coherence API and must be compiled with your application. The header files are available under the installation's include directory. The include directory must be part of your compiler's include search path.

6.3 Linking the Coherence Library

Coherence for C++ ships with a release version of the Coherence library. This library is also suitable for linking with debug versions of application code. The library is located in the installation's lib directory. During linking, this directory must be part of your linkers library path.

Table 6-3 Names of Linking Libraries for Release and Debug Versions

Operating System Library

Windows

coherence.lib

Solaris

libcoherence.so

Linux

libcoherence.so

Apple OS X

libcoherence.dylib


6.4 Setting the run-time Library and Search Path

During execution of a Coherence enabled application the Coherence for C++ shared library must be available from your application's library search path. This is achieved by adding the directory which contains the shared library to an operating system dependent environment variable. The installation includes libraries in its lib subdirectory.

Table 6-4 Name of the Coherence for C++ Library and Environment Variables

Operating System Environment Variable

Windows

PATH

Solaris

LD_LIBRARY_PATH

Linux

LD_LIBRARY_PATH

Apple (Mac) OS X

DYLD_LIBRARY_PATH


For example, to set the PATH environment variable on Windows execute:

c:\coherence\coherence-cpp\examples> set PATH=%PATH%;c:\coherence\coherence-cpp\lib

As with the Java version of Coherence, the C++ version supports a concept of System Properties to override configuration defaults. System Properties in C++ are set by using standard operating system environment variables, and use the same names as their Java counterparts. The tangosol.coherence.cacheconfig system property specifies the location of the cache configuration file. You may also set the configuration location programmatically (CacheFactory::configure()) from application code, the examples however do not do this.

Table 6-5 Cache Configuration System Property Value for Various Operating Systems

Operating System System Property

Windows

tangosol.coherence.cacheconfig

Linux

TangosolCoherenceCacheConfig

Solaris

TangosolCoherenceCacheConfig

Apple (Mac) OS X

TangosolCoherenceCacheConfig


Note:

Some operating system shells, such as the UNIX bash shell, do not support environment variables which include the '.' character. In this case, you may specify the name in camel case, where the first letter, and every letter following a '.' is capitalized. That is, "tangosol.coherence.cacheconfig" becomes "TangosolCoherenceCacheConfig".

For example, to set the configuration location on Windows execute:

c:\coherence\coherence-cpp\examples> set tangosol.coherence.cacheconfig=config\extend-cache-config.xml

6.5 Deploying Coherence for C++

Coherence for C++ requires no specialized deployment configuration. Simply link your application with the Coherence library. See the C++ examples included in the Coherence Examples for sample build scripts and configuration. The examples are included as part of the Coherence for Java distribution.

Note:

When deploying to Microsoft Windows the Visual Studio 2005 SP1 C++ run-time libraries are required. To build the samples, a version of Visual Studio 2005 SP1 or higher is required.