We've encountered some problems with mysql detection in NDOUtils - it doesn't work on one of our redhat servers. The specific problem is that the ceil function is not found, which is because -lm is missing from the list of libraries to add at link time:
utils.o(.text+0x14e): In function `ndo_dbuf_strcat':
: undefined reference to `ceil'
collect2: ld returned 1 exit status
Rather than adding that library in manually (along with the -lz library that we found earlier for Mac OS X), we should use information from mysql_config to construct the compile flags. However, this is a bit tricky because of the various permutations.
Fortunately, the Nagios Plugins have a solution already. They have an m4 file, called np_mysqlclient.m4, that is used to detect mysql_config and this returns data from the msyql_config for configure to use.
So we've patched NDOUtils so that it uses this m4 file now. In order to use, you have to apply the patch to configure.in, add a new m4/ directory to the top level and copy np_mysqlclient.m4 into m4/. Then run:
aclocal -I m4
autoconf
./configure --with-mysql=DIR
The detection is the same as in the Nagios Plugins: ./configure will try to find mysql_config in DIR/bin/mysql_config, otherwise will look in the PATH.
The nice thing is that if the logic for detection needs to be enhanced, we can update the m4 file and propagate the changes back to the Nagios Plugins as well. So everyone wins!
There's also a patch for CFLAGS in src/Makefile.in (which were getting overridden - presumably for testing), a small header change in config.h.in and some Makefile.in changes because make errors were getting lost by the cd .. command.
We've tested this on a Mac OS X server, a Debian Etch server, and 32bit and 64bit Redhat, and it is looking good.
Unfortunately, it means deprecating the --with-mysql-inc and --with-mysql-lib configure options. Hopefully, you'll see why this way is so much nicer.
Here's the patch against CVS HEAD.
Update: Here's the patch, reworked for NDOutils 1.4b3
Update: You can get the tarball with just this patch here
i had same problems with the undefined reference to ceil. I solved it by adding -lm in the linker definitions in the makefile.
Posted by: paul | May 17, 2007 at 01:30 PM
Paul,
Did you still need the -lm with this patch? Does mysql_config show -lm in the --libs flags?
Ton
Posted by: tonvoon | May 18, 2007 at 09:24 AM
Running FC6 x86_64 I had to use:
./configure --enable-pgsql=no \
--with-mysql-lib=/usr/lib64/mysql \
--with-mysql-inc=/usr/include/mysql/
and I didn't need to add -lm to the compile options.
Posted by: Jonas | June 28, 2007 at 10:26 PM
Jonas,
So the -lm without this patch worked? What was the output of mysql_config? It could be that your version of mysqlclient didn't require the math library.
Ton
Posted by: tonvoon | July 2, 2007 at 11:19 AM
Ton,
I have Nagios 2.5 and i have installed the patch for NDOutils 1.4b7 in order to resolve problems of detection Mysql library (mysql.h). But, when I patched Ndoutils, there is still this error even if i have specified the path directory of mysql_config. In addition to that i don't have this output :
"checking for mysql_config... /usr/local/mysql/bin/mysql_config"
The checks stop at :
"checking for linker flags for loadable modules... -shared"
Can you help me please ?
Thanks.
Posted by: fatphaze | March 30, 2009 at 04:02 PM