[Nut-upsdev] SNMP And SuSE

Eric Wilde ewilde at gntrains.com
Sat Jan 29 20:48:39 UTC 2011


At 12:06 PM 1/29/2011 +0000, you wrote:
>The script is not able to find the required libraries, it doesn't say
>they don't exist. In order to find out what's wrong, we really need
>the 'config.log' that is generated.

Fair enough.  The germane portion of the config.log file is:

   configure:7703: checking for init_snmp
   configure:7703: gcc -o conftest -DINET6 -O2 -fmessage-length=0 -Wall 
-D_FORTIFY_SOURCE=2 -g -fno-strict-aliasing -fstack-protector-all -Dlinux 
-I/usr/include/rpm -I/usr/include   conftest.c -L/usr/lib64 -lnetsnmp 
-lcrypto -lm -L/usr/lib -lwrap >&5
   /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/bin/ld: 
cannot find -lwrap
   collect2: ld returned 1 exit status

As you know, configure can be asked to test for the presence of a library
by building a small program that references a well-known entry point in
that library and then running it through the compiler/linker.  This not
only tests that the library is there but that the options given to
configure actually work when compiling and/or linking.

In this case, it is the bogus "-lwrap" returned by net-snmp-config that
is the problem, not the net-snmp library or where it is installed, etc.

>You also might be able to direct configure in the right direction by
>providing it with the --with-snmp-cflags and --with-snmp-libs options,
>instead of hacking configure.

You are correct.  Your response lead me to investigate the problem
further, rather than just hacking configure (to get things working).
You can override the libraries used for net-snmp as follows:

   --with-snmp-libs="-L /usr/lib64 -lnetsnmp -lcrypto -lm"

However, there is a "--without-wrap" option that can be supplied to the
"./configure" command.  Indeed, configure determines automatically that
there is no TCP wrappers library and turns that option off so it actually
knows that "-lwrap" will not work.

Since the point of configure is to figure out the user's system and
configure the build to "just work" on that system, the user should not
have to specify anything.  Since configure is correctly determining that
the TCP wrappers library is not installed, and since we now know that the
net-snmp-config script returns a library string that gratuitously includes
"-lwrap" on at least one system, we probably should fix the configure
script to remove "-lwrap" from that string, if the TCP wrappers library is
not installed.

As a test, I changed the configure file at the lines that look like:

   else
     LIBS="`net-snmp-config --libs 2>/dev/null`"
   fi

To instead read:

   else
     LIBS="`net-snmp-config --libs 2>/dev/null`"
     if test "x$nut_have_libwrap" != x""yes; then
       LIBS=`echo $LIBS | sed s/-lwrap//`
     fi
   fi

If the nut_have_libwrap variable is properly set to "no", this fixes the
problem.  The configure script runs correctly and "make" builds the
product properly.

To implement this fix, you will have to go back and make this change to
your aclocal.mc file, that generates the configure script.  Also, you'll
have to go back to your configure.ac file and change the order of the
tests so that the check for TCP wrappers library is done before the test
for net-snmp.  I don't believe reordering the tests will pose a problem.
I haven't given it that much thought but it does seem that the check for
net-snmp could simply be moved to the end, since there are no subsequent
steps that appear to depend on it.

Also, there may be other ramifications that I am not aware of but it
does not seem so.  If there is no libwrap installed on the system or the
user forces "--without-wrap", it seems a shame to fail their build
because net-snmp-config is misguided.

                                Eric Wilde





More information about the Nut-upsdev mailing list