[strongSwan-dev] WI: Support for monolithic builds

Tobias Brunner tobias at strongswan.org
Wed Mar 17 13:35:11 CET 2010

Work-Item: Support for monolithic builds

Branch: master

Schedule: 4.4.0

In some situations, it might be useful to build monolithic versions of
libstrongswan and charon.  That is, include all enabled plugins in the resulting
binary.  Because all plugins use the same name for their constructor (i.e.
plugin_create) a monolithic build is currently not possible.

API changes:
The main change is that all plugin constructors must be renamed to
plugin_name_plugin_create().  For example, the kernel-netlink plugin now uses a
constructor named kernel_netlink_plugin_create().  If you wrote your own plugin,
you will have to rename its constructor accordingly.  Additionally, if you want
to be able to add your plugin to a monolithic build, you will have to change the
Makefile.am of your plugin and of either libstrongswan or charon (the required
changes are listed below).

The monolithic build can be enabled using the --enable-monolithic configure
option.  Even if built monolithically, plugins are still loaded dynamically and
thus can be enabled/disabled using the charon.load option in strongswan.conf.
Enabling the monolithic build causes the plugins to be built and linked as
static libraries.  Because libtool does not provide an option to include the
complete archives (*.a) in executables (the unsupported linker option being
--whole-archive) we cannot link the statically built plugins directly to charon.
 The seemingly unused (due to the dynamic loading) plugin constructors would
simply get omitted while linking.  Therefore, we have to build an additional
shared library, libcharon, which contains all enabled plugins of charon.

Makefile.am changes required to add a plugin to the monolithic build:

    plugin_LTLIBRARIES = libstrongswan-plugin-name.la
    noinst_LTLIBRARIES = libstrongswan-plugin-name.la
    plugin_LTLIBRARIES = libstrongswan-plugin-name.la

      libcharon_la_LIBADD += plugins/plugin_name/libstrongswan-plugin-name.la
  after the line
    SUBDIRS += plugins/plugin_name

libstrongswan: same as above, just replace libcharon_la with libstrongswan_la

More information about the Dev mailing list