Using the command line and nmake (VC++ 2010 Express)
From Net-SNMP Wiki
Setup the build system
- Download and install Microsoft Visual C++ 2008 Express [1]
- Download and install Microsoft Visual C++ 2010 Express [2]
- Download and install Windows SDK v7.1 [3]
- Download and install ActivePerl v.5.16.3.1604 (x64) for the Make scripts and/or Perl Net-SNMP modules [4]
- Download Win64 OpenSSL v1.0.1j (full), extract to C:\OpenSSL [5]
- Download Net-SNMP v5.7.2.1 ZIP [6], extract to path without spaces (e.g. C:\projects\net-snmp-5.7.2.1)
Edit .\snmplib\read_config.c, move line 545 to line 539.
Microsoft Visual C++ does not follow the C99 code standard and therefore does not permit variable declaration in the middle of a code block.
Before:
538: if (when == EITHER_CONFIG || lptr->config_time == when) { 539: DEBUGMSGTL(("read_config:parser", 540: "Found a parser. Calling it: %s / %s\n", token, 541: cptr)); 542: /* 543: * Make sure cptr is non-null 544: */ 545: char tmpbuf[1]; 546: if (!cptr) { 547: tmpbuf[0] = '\0'; 548: cptr = tmpbuf; 549: }
After:
538: if (when == EITHER_CONFIG || lptr->config_time == when) { 539: char tmpbuf[1]; 540: DEBUGMSGTL(("read_config:parser", 541: "Found a parser. Calling it: %s / %s\n", token, 542: cptr)); 543: /* 544: * Make sure cptr is non-null 545: */ 546: if (!cptr) { 547: tmpbuf[0] = '\0'; 548: cptr = tmpbuf; 549: }
Build Net-SNMP
Open a command prompt with the correct options:
- cmd /V:ON /E:ON
Set the environment variables for Visual Studio as well as the SDK (modify paths to match your install locations)
- C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\setenv.cmd /release /x64
Set the install directory variable to what Net-SNMP expects
- SET VCINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\
Append the following environment variables to include OpenSSL headers and libraries
- SET INCLUDE=%INCLUDE%;C:\OpenSSL\include
- SET LIB=%LIB%;C:\OpenSSL\lib\VC
Run the build script
- c:\projects\net-snmp-5.7.2.1\win32\build.bat
Common Issues
- The build process fails while running Perl module tests. Restart Windows after installing ActivePerl