How To Use Shared Libraries

Stratego -- Strategies for Program Transformation
From StrategoXT 0.11 the Stratego Runtime creates libraries using Libtool. This means that on platforms that support shared libraries, both static and shared libraries are constructed. In general, linkers prefer shared libraries over static libraries, thus Stratego programs will be linked with shared libraries.

This introduces the usual advantages and disadvantages of shared libraries. For example, an advantages is executables are smaller and the code of the runtime is shared. The disadvantage is that the libraries need the be found when the executable is invoked. This is a common problem for all packages that are using shared libraries.

Some methods to avoid the disadvantages are:

  • Use Libtool for linking in your package that uses StrategoXT. Libtool will add the directories of dynamic libraries to the search path of the executables. This solves the problem of run-time lookup of a shared library that is not installed in a default directory for libraries at your system.

  • If programs are not linked in this way, then the user can set the LD_LIBRARY_PATH to include the location of the Stratego runtime libraries in the StrategoXT installation.

  • If you just hate dynamic libraries, then you can configure StrategoXT with the standard Libtool option --disable-shared: ./configure ... --disable-shared. This will only construct static libraries.

  • Configure your own package with the -static option in LDFLAGS: ./configure ... LDFLAGS=-static.