Linux Plugins

From Synfig Studio :: Documentation
Jump to: navigation, search
(Building plugins: adding link to libltdl at gnu.org)
(Using libltdl for plug-ins: replace lt_dladvise_init by lt_dlsym)
 
Line 20: Line 20:
 
<pre>
 
<pre>
 
AC_CHECK_HEADER([ltdl.h],
 
AC_CHECK_HEADER([ltdl.h],
     [AC_CHECK_LIB([ltdl], [lt_dladvise_init],
+
     [AC_CHECK_LIB([ltdl], [lt_dlsym],
 
         [LIBLTDL=-lltdl], [LIBLTDL=])],
 
         [LIBLTDL=-lltdl], [LIBLTDL=])],
 
     [LIBLTDL=])
 
     [LIBLTDL=])
 
</pre>
 
</pre>
It's important to check for a function that is present in the currently-supported version of libltdl. This snippet checks for the lt_dladvise_init function that is a new interface present in libtool 2.2 and later.
+
It's important to check for a function that is present in the currently-supported version of libltdl. This snippet checks for the lt_dlsym function that is a new interface present in libtool 2.2 and later.

Latest revision as of 17:37, 26 November 2010

Building plugins

The shared objects technology is used, among other things, to provide the so-called “plug-in system”, that allows us to link in compiled code at runtime providing (eventually optional) features [1]. Software that is interested in wider portability among different operating systems will be interested instead in using the wrapper library and interface called libltdl [2].

Using libltdl for plug-ins

Because of the wide adoption of libltdl in many types of applications, it's support in autotools is available with huge flexibility. This is because it's wrapping abilities can easily be used on systems where libtool proper is not usually installed, and thus it's often convenient to have a local copy of it. This is wrong, on linux system the used of the system library libltdl should be require, like any other required libraries.

There is no provided macro to check for the library in the system to simply rely on that; since it also does not provide a pkg-config datafile, the best practices choice is simply to discover the library through AC_CHECK_LIB.

To do that you can use the following snippet of code, for instance:

Example 3.4. Checking for libltdl

AC_CHECK_HEADER([ltdl.h],
    [AC_CHECK_LIB([ltdl], [lt_dlsym],
        [LIBLTDL=-lltdl], [LIBLTDL=])],
    [LIBLTDL=])

It's important to check for a function that is present in the currently-supported version of libltdl. This snippet checks for the lt_dlsym function that is a new interface present in libtool 2.2 and later.