On tis, 2008-05-20 at 09:40 +0800, Tewen Hsieh wrote:
> Hi,
>  
> as title~
>  
> I am not familiar with writing makefile.
> There is just a scalar sample can be found at net-snmp
> tutorials(http://net-snmp.sourceforge.net/wiki/index.php/Tutorials).
> If I want to write a dynamic loadable object of a table (ex: ifTable),
> how can I write the makefile?
> Is there a makefile template can be referenced?

Not that I am aware of.
When I am to generate a small shared object for testing I usually do as
follows:

        net-snmp-config --compile-subagent scalar_int \
        /path/to/src/net-snmp/agent/mibgroup/examples/scalar_int.c

in order to get myself a nice command line. This command outputs

generating the tmporary code file: netsnmptmp.14888.c
checking for init_scalar_int in 
/path/to/src/net-snmp/agent/mibgroup/examples/scalar_int.c
init_scalar_int(void)
checking for shutdown_scalar_int in 
/path/to/src/net-snmp/agent/mibgroup/examples/scalar_int.c
running: gcc  -DNETSNMP_ENABLE_IPV6 -g -Ulinux -Dlinux=linux -I/usr/include/rpm 
-Wall -Winline -Wstrict-prototypes -Wwrite-strings -Wcast-qual 
-Wno-char-subscripts -I. -I/path/to/include -o scalar_int netsnmptmp.14888.c  
/path/to/src/net-snmp/agent/mibgroup/examples/scalar_int.c  -L/path/to/lib 
-lnetsnmpagent -lnetsnmphelpers -lnetsnmpmibs -lnetsnmp   
netsnmptmp.14888.c: In function 'main':
netsnmptmp.14888.c:200: warning: implicit declaration of function 
'init_scalar_int'
removing the tmporary code file: netsnmptmp.14888.c
subagent program scalar_int created

>From this I take the line running: gcc ... and modifies it by removing
the temp file, changing the name of the output file and adding the
-shared option as follows:

gcc  -DNETSNMP_ENABLE_IPV6 -g -Ulinux -Dlinux=linux \
-I/usr/include/rpm  -Wall -Winline -Wstrict-prototypes -Wwrite-strings \
-Wcast-qual -Wno-char-subscripts -I. -I/path/to/include \
-o scalar_int.so -shared \
/path/to/src/net-snmp/agent/mibgroup/examples/scalar_int.c \
-L/path/to/lib -lnetsnmpagent -lnetsnmphelpers \
-lnetsnmpmibs -lnetsnmp

/MF



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft 
Defy all challenges. Microsoft(R) Visual Studio 2008. 
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to