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 usingCMake, it should be able to generate the correct compilation commands for your system. If the library is namedsomepluglib, you should end up with a shared library file that has a name something likesomepluglib.so. (The.so file name suffix might differ on your system.)
To useCMake, you'll need to set up the configuration files to enable the plugin to be compiled and installed. Use the plugin examples under theplugin directory of a MySQL source distribution as a guide.
CreateCMakeLists.txt, which should look something like this:
MYSQL_ADD_PLUGIN(somepluglib somepluglib.c MODULE_ONLY MODULE_OUTPUT_NAME "somepluglib") WhenCMake generates theMakefile, it should take care of passing to the compilation command the-DMYSQL_DYNAMIC_PLUGIN flag, and passing to the linker the-lmysqlservices flag, which is needed to link in any functions from services provided through the plugin services interface. SeeMySQL Plugin Services.
RunCMake, then runmake:
$> cmake .$> make If you need to specify configuration options toCMake, seeMySQL Source-Configuration Options, for a list. For example, you might want to specifyCMAKE_INSTALL_PREFIX to indicate the MySQL base directory under which the plugin should be installed. You can see what value to use for this option withSHOW 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 theplugin_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, usemake:
$> make installVerify thatmake 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.