Using the command line and nmake (VC++ 2010 Express)

From Net-SNMP Wiki
Revision as of 19:10, 10 November 2014 by Mikeycnp (Talk | contribs)

Jump to: navigation, search

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), install 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)

Visual C++ 2010 Express cannot open/convert Visual C++ 6.0 projects.

Use Visual C++ 2008 Express to open C:\projects\net-snmp-5.7.2.1\win32\win32.dsw and convert the Solution and corresponding Projects to a recent Visual Studio version. Afterwards, you can open the resulting Solution with VC++ 2010 Express.

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 Visual C++ install directory environment 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

Change the following options to "enable" the corresponding features

  • 1 OpenSSL support enabled
  • 2 Platform SDK support enabled
  • 5 Perl modules enabled
  • 6 Install perl modules enabled
  • 9 IPv6 transports enabled
  • 10 winExtDLL agent enabled
  • 11 Link type dynamic

Press 'F', followed by Enter to finish and start building.

Common Issues

  • The build process fails while running Perl module tests. Restart Windows after installing ActivePerl