October 13, 2008

build net-snmp on Windows

This is how to build net-snmp (version 5.4.2) on windows :

0. install MS visual Studio Express 2008 VC++

0.1 build openssl, copy headers and libs to visual studio include and lib directories according to net-snmp readme.WIN32

1. read file readme.WIN32 section "Manual build using Configure / nmake"

2. cd win32

3. change file build.pl line 34

#if (! (-d $ENV{MSVCDir})) {
to
if (! (-d $ENV{VCINSTALLDIR})) {

4. perl Configure --with-sdk --with-ssl --config=debug --prefix="c:/usr"

5. add the following code to the beginning of win32\net-snmp\net-snmp-config.h
#include
#include

#ifdef WIN32
#include "windows.h"
#include "winsock.h"
#include "iprtrmib.h"
#include "tlhelp32.h"
#include "iphlpapi.h"
#endif
also
change NETSNMP_DEFAULT_MIBS to:
#define NETSNMP_DEFAULT_MIBS "IF-MIB"

6. in file c:\tools\net-snmp-5.4.2\win32\netsnmpmibssdk\Makefile
comment out the 2 lines containing "winExtDLL.obj"

7. in file C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\openssl/ossl_typ.h
comment out these two lines:
//typedef struct ocsp_response_st OCSP_RESPONSE;
//typedef struct ocsp_responder_id_st OCSP_RESPID;

8. in file snmplib\snmpTcpDomain.c, remove 2 includes files, and add socketlen_t define
#if HAVE_WINSOCK_H
#define socklen_t int
//#include
//#include
#endif

9. repeat last step for file snmplib\snmpUdpDomain.c, apps\snmpnetstat\inet.c, apps\snmpnetstat\inet6.c
10. nmake (you will see warnings about /YX, GX and unsafe use of strcpy, etc. they are safe to ignore for now.

I wish it is easier than this. Maybe next year. :-)

No comments:

Post a Comment