Developing C++ Programs on Linux
This section describes how to build and run a native client application on Linux.
Note: When compiling external projects or applications that are used or referenced by the Geode native client, make sure that you compile them for the same target architecture as your native client installation. For example, if you installed the 64-bit (x86) version of the native client, compile your external projects for 64-bit (x86) architecture.
Set the native client environment variables on each Linux host. For each case, product-dir is the path to the native client product directory.
For Bourne and Korn shells (sh, ksh, bash)
On Linux, the
g++ compiler is supported. To build and link a C++ client to GemFire on Linux, the compilation command line must include the arguments listed in the following table.
||Required to compile Linux programs in a thread-safe way.|
||Enables 32-bit or 64-bit compilation.|
||Specifies the native client
The following table lists the linker switches that must be present on the command line when dynamically linking to the GemFire library.
||Tells the linker to look in
||Tells the linker where to find the named libraries.|
||Tells the linker to output an object file named ‘durableclient’.|
||Links the native client C++ cache library to the compiled executable.|
The following examples compile and link the
$GFCPP/SampleCode/quickstart/cpp/DurableClient.cpp client to the
durableclient output file.
Compiling and Dynamically Linking on Linux for 32-bit
g++ \ -D_REENTRANT \ -03 \ -Wall \ -m32 \ -I$GFCPP/include \ cpp/DurableClient.cpp \ cpp/plugins/DurableCacheListener.cpp \ -o cpp/DurableClient \ -L$GFCPP/lib \ -Wl,-rpath,$GFCPP/lib \ -lgfcppcache
Compiling and Dynamically Linking on Linux for 64-bit
g++ \ -D_REENTRANT \ -03 \ -Wall \ -m64 \ -I$GFCPP/include \ cpp/DurableClient.cpp \ cpp/plugins/DurableCacheListener.cpp \ -o cpp/DurableClient \ -L$GFCPP/lib \ -Wl,-rpath,$GFCPP/lib \ -lgfcppcache
When the C++ application is dynamically linked to the native client library, the library must be dynamically loadable.
To ensure that the native client library is available for loading, make sure you have added the path product-dir
/lib to the LD_LIBRARY_PATH environment variable, where product-dir is the path to the Geode product directory.