Doubt in connecting to mysql database from plugin

Andreas Ericsson ae at op5.se
Thu Jan 6 16:22:02 CET 2005


Jlnarayanan00 at aol.com wrote:
>   
> Hi ,
>  
>     I had raised a doubt regarding connecting to mysql database from the 
> plugin.As per the solution that was suggested yesterday I have included the path 
> where the libmysqlclient.so.* file is present in the /etc/ld.so.conf. file.
>  
> If  I give a command “locate libmysqlclient” in my system ,I am getting the 
> following output.
>  
> []$ locate libmysqlclient
> /usr/lib/mysql/libmysqlclient.la
> /usr/lib/mysql/libmysqlclient_r.la
> /usr/lib/mysql/libmysqlclient.a
> /usr/lib/mysql/libmysqlclient_r.a
> /usr/lib/libmysqlclient.so
> /usr/lib/libmysqlclient.so.10.0.0
> /usr/lib/libmysqlclient.so.10
> /usr/lib/libmysqlclient.so.14.0.0
> /usr/lib/libmysqlclient.so.14
> /usr/lib/libmysqlclient_r.so.10
> /usr/lib/libmysqlclient_r.so
> /usr/lib/libmysqlclient_r.so.10.0.0
> /usr/lib/libmysqlclient_r.so.14
> /usr/lib/libmysqlclient_r.so.14.0.0
>  
> So after adding the path in the /etc/ld.so.conf file 
>  
> [root at localhost etc]# cat ld.so.conf
> /usr/kerberos/lib
> /usr/X11R6/lib
> /usr/lib/sane
> /usr/lib/qt-3.1/lib
> /usr/lib/mysql
>  
>  
> While giving “make all” command for the plugins I am getting the following 
> error still
>  
> undefined reference to `mysql_init'
> undefined reference to `mysql_real_connect' …….
>  
> But while trying to compiling the plugin from the command prompt by giving 
> the following command ,
> gcc -o check_dummy1 check_dummy1.c -I/usr/include/mysql -L/usr/lib/mysql 
> -lmysqlclient -lz -fno-exceptions
>  {check_dummy1 is the plugin in which i have coded to connect to the mysql 
> database}
> 
> I am not getting the error as undefined reference to “mysql_init” and other 
> mysql related functions.{But the error I am getting is undefined reference for 
> the functions that are common to all plugins like “undefined reference to 
> `print_revision'” which I understand should come.}
>  
> Now where should I make changes for linking with the mysql client library 
> which is the problem as far i understand.
> Can anybody please help me out in this issue??
>  

You understand wrong. With all due respect, I seriously doubt that you 
are quite competent enough to make your plugin work if you aren't 
experienced enough to solve simple linking issues like these.

The solution to your problem is to link the object file of check_dummy1 
with the object file of the utils.c file. gcc can do this on the fly for 
you so you don't necessarily have to run gcc -c on both the files first, 
but if you intend to make changes to one but not both of the files I 
would recommend you to compile the other into object form first.

For more information, run
man gcc; man ld
on any GNU system and read the relevant parts of both.

-- 
Andreas Ericsson                   andreas.ericsson at op5.se
OP5 AB                             www.op5.se
Lead Developer


-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list