Talk:TUT:Simple Application

From Net-SNMP Wiki
Revision as of 19:43, 13 September 2007 by Igor (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The example Makefile is a little big. The following worked for me:

Makefile:

   #
   # Warning: you may need more libraries than are included here on the
   # build line.  The agent frequently needs various libraries in order
   # to compile pieces of it, but is OS dependent and we can't list all
   # the combinations here.  Instead, look at the libraries that were
   # used when linking the snmpd master agent and copy those to this
   # file.
   #
   
   CC=gcc
   
   OBJS1=snmpdemoapp.o
   TARGETS=snmpdemoapp
   
   CFLAGS=-I. `net-snmp-config --cflags`
   BUILDLIBS=`net-snmp-config --libs`
   BUILDAGENTLIBS=`net-snmp-config --agent-libs`
   
   # shared library flags (assumes gcc)
   DLFLAGS=-fPIC -shared
   
   all: $(TARGETS)
   
   snmpdemoapp: $(OBJS1)
   	$(CC) -o snmpdemoapp $(OBJS1) $(BUILDLIBS)
   
   clean:
   	rm  $(TARGETS)


Output:


   [igor@ ~/snmp_client_00]$ make
   gcc -I. `net-snmp-config --cflags` -c snmpdemoapp.c
   gcc -o snmpdemoapp snmpdemoapp.o `net-snmp-config --libs`
   [igor@ ~/snmp_client_00]$ ./snmpdemoapp 
   SNMPv2-MIB::sysDescr.0 = STRING: FreeBSD snmptest.netsec.tislabs.com 5.4-RELEASE-p9 FreeBSD 5.4-RELEASE-p9 #0: Thu Jan 12 05:31:33 UTC 2006     root@zathras.netsec.tislabs.com:/usr/obj/usr/src/sys/GENERIC i386
   value #1 is a string: FreeBSD snmptest.netsec.tislabs.com 5.4-RELEASE-p9 FreeBSD 5.4-RELEASE-p9 #0: Thu Jan 12 05:31:33 UTC 2006     root@zathras.netsec.tislabs.com:/usr/obj/usr/src/sys/GENERIC i386