The framework for embedding Mozilla technologies was at one point called the GRE (Gecko Runtime Environment). This embedding framework allows applications to locate a compatible Gecko runtime and embed it without knowing in advance where that runtime will be installed. This document describes how embedders should dynamically link to a GRE. To understand how GREs are registered, see GRE Registration.
The XRE project, which means "XUL Runtime Environment", has been replaced by XULRunner.
There are two different forms for the GRE: the "old" GRE was part of the Mozilla application suite. It was installed with the Windows installer of Mozilla 1.4 through 1.7.x. There was never an official GRE shipped for Linux, but various distributors such as Red Hat have registered Mozilla installations as if they were a GRE. The Mozilla suite never supported a GRE on Mac.
XULRunner is the new version of the GRE, which not only allows embedding but is capable of bootstrapping entire XUL applications such as Firefox. XULRunner supports or is planned to support embedding on all three major platforms (Windows, Mac, and Linux).
If an application wishes to use the GRE, it must take careful steps to ensure that it links against the proper libraries. If you link directly against xpcom.dll/libxpcom.so
(xpcom.lib
import lib), your application will not launch unless xpcom.dll is in your PATH
. This prevents dynamically finding a compatible GRE at runtime.
Note: Support for locating a standalone glue was removed in Gecko 6.0.
To find a compatible GRE, you should use the function GRE_GetGREPathWithProperties()
(declared in xpcom/glue/standalone/nsXPCOMGlue.h
). This allows the embedder to specify what version(s) of GRE are appropriate, and to specify any special features the GRE must have (currently there are no special features defined).
The solution is to statically link against xpcomglue.lib
, also known as the "standalone glue" (see XPCOM Glue). This library provides a layer of indirection between embedding code and XPCOM. To use the XPCOM glue, you must follow these steps:
XPCOM_GLUE
defined.xpcomglue.lib
(not xpcomglue_s.lib
!). Don't link against the NSPR libs.XPCOMGlueStartup()
function. See environment variables below.XPCOMGlueShutdown()
.The XULRunner GRE is designed so that the embedder does not need to set any environment variables such as PATH
or LD_LIBRARY_PATH
before calling XPCOMGlueStartup()
, because it dynamically loads the correct dependent libraries. Unfortunately, the Mozilla suite-based GRE is not as forgiving, especially on Linux. Embedders will need to set the LD_LIBRARY_PATH
environment variable and start a new process in order to embed a suite-based GRE correctly.