Hello,
Usually when we want to declare one or more plugins we use two macros
defined in plugin.h: mysql_declare_plugin and mysql_declare_plugin_end
(http://dev.mysql.com/doc/refman/6.0/en/plugin-creating.html). It works just
fine until the implementation is within a single file. If you try to declare
plugins in separate files using the macros above, the compiler will complain
about multiple definitions of _mysql_plugin_interface_version_ and
_mysql_plugin_declarations_. Now what I did - suppose we have two files
plugin_1.cc and plugin_2.cc. plugin_1.cc contains only functions and data
structures needed by plugin_1 and the same for plugin_2.cc
Simplified plugin_1.cc:
//plugin_1.cc
.....
struct st_mysql_plugin plugin_1= {....};
.....
//plugin_2.cc
.....
struct st_mysql_plugin plugin_2= {....};
.....
Then I add one file to declare plugins manually without using macros.
//init.cc
extern st_mysql_plugin plugin_1;
extern st_mysql_plugin plugin_2;
struct st_mysql_plugin dummy=
{0,0,0,0,0,0,0,0,0,0,0,0};
int _mysql_plugin_interface_version_= MYSQL_PLUGIN_INTERFACE_VERSION;
struct st_mysql_plugin _mysql_plugin_declarations_=
{
plugin_1,
plugin_2,
dummy
};
It compiles and runs without errors. But my question - is it correct to
declare plugins this way or maybe there should be another approach. I just
couldn't find any documentation or examples which would match my case.
Cheers,
M.Chochlovas