Using Plugins with Static Libraries

When an Ice plug-in is packaged in a static library, you need to link your application with the plug-in's static library and call a register function from your application to ensure the corresponding code gets correctly included.

Linux Only

You need to call these register functions when linking with static libraries on Linux. On other platforms, all Ice plug-ins included in the Ice static library are registered automatically.

Ice provides the following plug-in registration functions:

C++
namespace Ice
{
    void registerIceDiscovery(bool loadOnInitialize = true);
    void registerIceLocatorDiscovery(bool loadOnInitialize = true);
    void registerIceSSL(bool loadOnInitialize = true);
    void registerIceStringConverter(bool loadOnInitialize = true);
}

For example, if you are using a static IceSSL plug-in, link your application with libIce.a and call Ice::registerIceSSL from your application. All Ice plug-ins (IceDiscovery, IceLocatorDiscovery and IceSSL) are included in the Ice static library (libIce.a).

When the bool parameter is true (the default), the plug-in is always loaded (created) during communicator initialization, even if Ice.Plugin.name is not set. When false, the plug-in is loaded (created) during communication initialization only if Ice.Plugin.name is set to a non-empty value (e.g., Ice.Plugin.IceSSL=1).

The table below summarizes the registration functions:

Plug-in NameFunctionalityFunction
IceStringConverterconvert native string encoding to/from UTF-8Ice::registerIceStringConverter
IceSSLicessl transportIce::registerIceSSL
IceDiscoveryLocation service implemented using UDP multicastIce::registerIceDiscovery
IceLocatorDiscoveryLocation service implemented using UDP multicastIce::registerIceLocatorDiscovery
If you are developing your own plug-in, you will also need to register your plug-in factory function using Ice::registerPluginFactory. Refer to the Plug-in API for more information on this function.