Skip to content

Ganglia GMond Native Windows

Ng Zhi An edited this page Jul 27, 2014 · 1 revision

Preparing a Ganglia gmond native Windows binary

This page is for collecting ideas about how to compile a native Windows version of gmond.

The current version of gmond on Windows is compiled as a Cygwin application. This means that it depends on (and is limited by) the Cygwin environment and DLL for performing some C library functions and providing an interface to system metrics.

A native binary reads the system metrics directly from the OS, using a mechanism known as WMI provided by the OS vendor.

Compiling

The Cygwin binary is compiled by the GCC binary included with Cygwin. Various other GNU tools (autoconf and friends) are also included in Cygwin, and used to prepare the source tree for a Cygwin build in much the same way as they are when building in a real UNIX environment. For building a native binary on Windows, these options are available:

Tools Benefits Disadvantages
CYGWIN versions of GNU tools GCC, autoconf, automake, etc (using GCC's -mno-cygwin for `cross compiling' a non-Cygwin binary) Consistency with the UNIX build procedure
Microsoft Visual C Popular tool among Windows developers. Includes Windows headers and stuff relating to WMI. Requires duplication of the makefiles Microsoft's equivalents to Makefiles are in a proprietary format and may not be suitable for an open source project
MinGW (also known as MinGW32) Consistency with the UNIX build procedure No need to install full Cygwin Can be run on a Linux host as a cross-compiler to build Windows executables

Cross compiling with Cygwin

When GCC is invoked under Cygwin, it will typically make a binary that links with CYGWIN1.DLL, using the Cygwin runtime to do things like I/O and emulation of some parts of the C library that are not provided by the Windows API. br However, it is not mandatory to use GCC in this way. By passing the -mno-cygwin option to GCC, it can be forced to build a binary that does not link with CYGWIN1.DLL. This has various benefits:

  1. Cygwin licensing constraints are avoided. Only Ganglia license applies.
  2. Less likelihood of problems on systems having multiple copies of CYGWIN1.DLL installed on the hard disk.
  3. No exposure to security issues in CYGWIN1.DLL, reducing the risk of a costly re-deployment of the application in a large enterprise.

Implementation steps

This list is not meant to be complete, and is currently considered a work in progress. Please feel free to add suggestions:

  1. Modify configure.in to include an option for the Windows native build
  2. Modify configure.in to add -mno-cygwin to CFLAGS when doing a Windows native build
  3. Inclusion of any necessary header files for Windows (or provide a script that simplifies the process of finding these files on the local hard disk)
  4. Investigate any C library functions that are not provided natively, and include an appropriately licensed alternative in gmond, re-implement the function, or modify gmond so that it doesn't use the function.
  5. Development of metric module implementations using WMI
  6. Creation of MSI file for the Windows installer

C library issues

  1. POSIX threads - resolved in trunk

Linking issues ==

  1. libConfuse must be linked statically
  2. metric modules - can these be dynamically linked?
  3. metric modules for WMI must be C++, gmond in trunk supports C++ metric modules
  4. APR on Windows - static or dynamic?

Replacing #ifdef CYGWIN

The CYGWIN compiler variable may need to be complemented with some additional variables:
#define OS_WINDOWS ''set if compiling either Windows variant, Cygwin or native
#define CYGWIN'' set if compiling without -mno-cygwin
#define WIN_NATIVE // set if compiling on MinGW, Visual C or CYGWIN with -mno-cygwin