Nagios with MySQL compilation problems on Redhat 6.2, 7.3, 8.0, 9.0 and Solaris 8 - SOME POSSIBLE FIXES

James Turnbull james at lovedthanlost.net
Wed Jul 9 01:57:18 CEST 2003


Whilst getting Nagios to work with MySQL I encountered a number of
compilation problems (which a number of people on this list have also
experienced - I counted at least 30 posts with the same error messages).  I
got these problems occurring with both Nagios 1.0, 1.1 and the 1-x-cvs on
Redhat 8 and 9.  I have also gone through the list archives and listed in
the subject line all the other OS' for which people have posted the same
problem with compilation.

The problems I encountered were:

1.  After ./configure finds the MySQL libraries and includes
(using --with-mysql-lib and --with-mysql-inc) the 'make all' fails with:

../xdata/xrddb.c:41:25: mysql/mysql.h: No such file or directory

In order to get this to work I edited the following files:

xcddb.c
xdddb.c
xeddb.c
xrddb.c
xsddb.c

and explicitly told Nagios where to find the includes by changing:

#ifdef USE_XRDMYSQL

#include <mysql/mysql.h>
#include <mysql/errmsg.h>
#endif

to:

#ifdef USE_XRDMYSQL

#include "/usr/local/mysql/include/mysql.h"
#include "/usr/local/mysql/include/errmsg.h"
#endif

2.  After fixing this problem I run 'make all' again and get the following
errors:

/tmp/cccMNNgs.o: In function `xrddb_initialize':
/downloads/nagios-1.1/base/../xdata/xrddb.c:215: undefined reference to
`mysql_init'
/tmp/cccMNNgs.o: In function `xrddb_connect':
/downloads/nagios-1.1/base/../xdata/xrddb.c:252: undefined reference to
`mysql_real_connect'
/downloads/nagios-1.1/base/../xdata/xrddb.c:254: undefined reference to
`mysql_close'
etc, etc

I discovered this related to Nagios being unable to find the MySQL libaries
(http://www.mysql.com/doc/en/Link_errors.html).

To fix this problems you need to place the LDFLAGS statements:

-L/usr/local/mysql/lib -lmysqlclient -lz

at the end of the compile statement after the file names like so:

gcc -g -O2 -I/usr/local/mysql/include -DHAVE_CONFIG_H -DNSCGI avail.c
getcgi.o cgiutils.o auth.o popen.o  ../common/objects.c
../xdata/xodtemplate.c ../common/statusdata.c ../xdata/xsddb.c -o
avail.cgi -L/usr/local/mysql/lib -lmysqlclient -lz

Not being a programmer I have no idea who to change the makefile to move the
LDFLAGS stuff to the end of the compilation statement so I manually compiled
each program - but I am sure one of the more programmer-orientated types can
explain how this is done.

Hope this helps some others with their compile problems.

Regards

James Turnbull



-------------------------------------------------------
This SF.Net email sponsored by: Parasoft
Error proof Web apps, automate testing & more.
Download & eval WebKing and get a free book.
www.parasoft.com/bulletproofapps
_______________________________________________
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