[Nagiosplug-devel] Problem compiling check_snmp.c on Solaris 8 [with fix?]

Khan Klatt khan at khan.org
Thu Sep 8 03:25:05 CEST 2005


First, forgive me if I'm not following proper conventions, this is my  
first contribution to an open source project, and I am not a C coder  
(outside of the odd hello_world.c)...

After struggling to get check_snmp to compile (all the other plugins  
compiled fine), I browsed the CVS tree, and got version 1.53 to  
compile "out of the box". It looks like the performance data  
enhancement in 1.54 caused the compile on Solaris 8 to break (SunOS  
ephemeral 5.8 Generic_108528-17 sun4u sparc SUNW,UltraSPARC-IIi- 
cEngine).

Specifically, this is the error I was getting after "./configure" and  
"make":

# make check_snmp
source='check_snmp.c' object='check_snmp.o' libtool=no \
depfile='.deps/check_snmp.Po' tmpdepfile='.deps/check_snmp.TPo' \
depmode=gcc /bin/bash ../depcomp \
gcc -DLOCALEDIR=\"/usr/local/nagios/share/locale\" -DHAVE_CONFIG_H - 
I. -I. -I.. -I.. -I../lib -I../intl   -I/usr/local/ssl/include  -g - 
O2 -c check_snmp.c
check_snmp.c: In function `main':
check_snmp.c:341: parse error before `char'
check_snmp.c:342: `str' undeclared (first use in this function)
check_snmp.c:342: (Each undeclared identifier is reported only once
check_snmp.c:342: for each function it appears in.)
make: *** [check_snmp.o] Error 1

After doing a bit of research on C tutorials, I came across this:
http://crasseux.com/books/ctutorial/...undeclared--first-use-in-this- 
function-.html
Which indicated that perhaps the string pointer (?) definition should  
be done outside of main{}

After making this "fix", it compiled cleanly:

# make check_snmp
source='check_snmp.c' object='check_snmp.o' libtool=no \
depfile='.deps/check_snmp.Po' tmpdepfile='.deps/check_snmp.TPo' \
depmode=gcc /bin/bash ../depcomp \
gcc -DLOCALEDIR=\"/usr/local/nagios/share/locale\" -DHAVE_CONFIG_H - 
I. -I. -I.. -I.. -I../lib -I../intl   -I/usr/local/ssl/include  -g - 
O2 -c check_snmp.c
source='utils.c' object='utils.o' libtool=no \
depfile='.deps/utils.Po' tmpdepfile='.deps/utils.TPo' \
depmode=gcc /bin/bash ../depcomp \
gcc -DLOCALEDIR=\"/usr/local/nagios/share/locale\" -DHAVE_CONFIG_H - 
I. -I. -I.. -I.. -I../lib -I../intl   -I/usr/local/ssl/include  -g - 
O2 -c utils.c
source='popen.c' object='popen.o' libtool=no \
depfile='.deps/popen.Po' tmpdepfile='.deps/popen.TPo' \
depmode=gcc /bin/bash ../depcomp \
gcc -DLOCALEDIR=\"/usr/local/nagios/share/locale\" -DHAVE_CONFIG_H - 
I. -I. -I.. -I.. -I../lib -I../intl   -I/usr/local/ssl/include  -g - 
O2 -c popen.c
gcc  -g -O2  -ldl -L. -R/usr/local/ssl/lib -L/usr/local/ssl/lib -o  
check_snmp  check_snmp.o utils.o ../lib/libnagiosplug.a ../lib/ 
libcoreutils.a popen.o ../intl/libintl.a  -lgen -lsocket  -I/usr/ 
local/ssl/include

If my fix is appropriate (i.e. doesn't break other builds), please  
consider applying the patch so that Solaris users will have more  
seamless installs out of the box. Patch diff below (basically moved  
line 341 -> 105)

Thanks, and constructive criticism welcomed... (If I look like I know  
what I'm doing, it's largely coincidental)

-K

-----------------

# diff -C0  *
*** check_snmp.c_1.57   Thu Sep  8 03:05:03 2005
--- check_snmp.c_1.58   Thu Sep  8 03:05:43 2005
***************
*** 104 ****
--- 105 ----
+ char *str[MAX_INPUT_BUFFER];
***************
*** 341 ****
-               char *str[MAX_INPUT_BUFFER];
--- 341 ----





More information about the Devel mailing list