After your plugin is written, you must compile it and install
it. The procedure for compiling shared objects varies from
system to system. If you build your library using the GNU
autotools, libtool should be able to
generate the correct compilation commands for your system. If
the library is named somepluglib, you
should end up with a shared object file that has a name
something like somepluglib.so. (The file
name might have a different suffix on your system.)
To use the autotools, you'll need to make a few changes to the
configuration files at this point to enable the plugin to be
compiled and installed. Assume that your MySQL distribution is
installed at a base directory of
/usr/local/mysql and that its header
files are located in the include
directory under the base directory.
Edit Makefile.am, which should look
something like this:
#Makefile.am example for a plugin pkgplugindir=$(libdir)/mysql/plugin INCLUDES= -I$(top_builddir)/include -I$(top_srcdir)/include #noinst_LTLIBRARIES= somepluglib.la pkgplugin_LTLIBRARIES= somepluglib.la somepluglib_la_SOURCES= plugin_example.c somepluglib_la_LDFLAGS= -module -rpath $(pkgplugindir) somepluglib_la_CFLAGS= -DMYSQL_DYNAMIC_PLUGIN
As mentioned in Section 22.2.4.2.1, “Library and Plugin Descriptors”,
be sure to specify -DMYSQL_DYNAMIC_PLUGIN
as part of the compilation command when you build the
plugin. The somepluglib_la_CFLAGS line
takes care of this.
Adjust the INCLUDES line to specify the
path name to the installed MySQL header files. Edit it to look
like this:
INCLUDES= -I/usr/local/mysql/include
Make sure that the noinst_LTLIBRARIES line
is commented out or remove it. Make sure that the
pkglib_LTLIBRARIES line is not commented
out; it enables the make install command.
Set up the files needed for the configure command, invoke it, and run make:
shell>autoreconf --force --install --symlinkshell>./configure --prefix=/usr/local/mysqlshell>make
The --prefix option to
configure indicates the MySQL base
directory under which the plugin should be installed. You can
see what value to use for this option with
SHOW VARIABLES:
mysql> SHOW VARIABLES LIKE 'basedir';
+---------------+------------------+
| Variable_name | Value |
+---------------+------------------+
| base | /usr/local/mysql |
+---------------+------------------+
The location of the plugin directory where you should install
the library is given by the
plugin_dir system variable.
For example:
mysql> SHOW VARIABLES LIKE 'plugin_dir';
+---------------+-----------------------------------+
| Variable_name | Value |
+---------------+-----------------------------------+
| plugin_dir | /usr/local/mysql/lib/mysql/plugin |
+---------------+-----------------------------------+
To install the plugin library, use make:
shell> make install
Verify that make install installed the plugin library in the proper directory. After installing it, make sure that the library permissions permit it to be executed by the server.

User Comments
Add your own comment.