Spec-Zone .ru
спецификации, руководства, описания, API
|
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 CMake
, it 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 CMake
, you'll need to set up the configuration files to enable the plugin to
be compiled and installed. Use the plugin examples under the plugin
directory of a
MySQL source distribution as a guide.
Create CMakeLists.txt
, which should look something like this:
MYSQL_ADD_PLUGIN(somepluglib somepluglib.c MODULE_ONLY MODULE_OUTPUT_NAME "somepluglib")
When CMake
generates the Makefile
, 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. See Section
23.2.5, "MySQL Services for Plugins".
Run CMake, then run make:
shell>cmake .
shell>make
If you need to specify configuration options to CMake, see Section 2.9.4, "MySQL Source-Configuration Options",
for a list. For example, you might want to specify CMAKE_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 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.