banner



How To Install Net Snmp

Specifically, we're talking

  • Windows 10
  • netsnmp v5.9.0
  • Visual Studio v2017, community edition - building static, release library (64 bit build)

Certain OPC-UA servers communicate with their target hardware using the SNMP protocol. For linux (centos7 distro anyway) building with SNMP is ~trivial: basically adding -lnetsnmp. Windows is rather more involved. In order to have the same netsnmp API between linux and windows servers, we opted for the open source netsnmp, from netsnmp.org. Available as a binary build via regular yum repos for CentOS, but the library has to be built by hand for windows. This document does not aim to replace, supersede, or disagree with the excellent windows build instructions available via net-snmp, which is maintained and distributed in the netsnmp source: file README.win32. All of the following steps were realised after reading through README.win32.

The goal

  • Start with download of the netsnmp source code archive.
  • Build static release library + headers to provide netsnmp functionality, x64 build, visual studio 2017 community.

The steps

  1. Obtain source zip file from netsnmp.org and extract contents to D:\3rdPartySoftware\net-snmp\5.9.0
  2. Open x64 vcvars command prompt for VS2017 (note this step assumes perl already installed - if not install active perl, put on PATH etc) and check perl Configure  works


  3. Configure build with following options; this generates files (header files only I think) specific to this build


  4. EDIT file win32/net-snmp/net-snmp-config.h by hand (before build)
    1. Remove redefinition of C++ keyword inline (net-snmp-config.h:1040).
      1. Explanation : if not, causes a VS2017 compile time error (redefinition of keyword)

    2. Undefine HAVE_SETLOCALE preprocessor macro ( net-snmp-config.h:664 ).
      1. Explanation : fairly weird this one. If not then during init_snmp() API call, the code will call setlocale(). Seems harmless enough, however, this function affects all character functions (printf and friends). On windows, if function setlocale is called, LogIt's logging runtime performance (in this instance, LogIt is just a thing that pumps characters to parent powershell window) decreases by factor ~10. There is [this case on bitbucket.org]

  5. Build library using nmake (from x64 vcvars cmd prompt). Note only building netsnmp library in this instance (executables etc. not required) - Makefile target: libsnmp
  6. Install: The Configure options for install (--prefix, --destdir) don't seem to work very well for static lib windows builds (*.lib missed, headers missing), so I manually 'installed' to directory INSTALLATION_RELEASE with a handmade script.
    1. Explanation : copies 'standard' netsnmp includes (excludes *.in files - only required during perl Configure step). Then copies some headers written during perl Configure step. Then copies static lib

      And same command repeated below to allow for copy paste of command
      del exclude.txt & ^
      echo .in >> exclude.txt & ^
      rmdir /S /Q D:\3rdPartySoftware\net-snmp\5.9.0\INSTALLATION_RELEASE\include\ & ^
      rmdir /S /Q D:\3rdPartySoftware\net-snmp\5.9.0\INSTALLATION_RELEASE\lib\ & ^
      xcopy /S /Y /EXCLUDE:exclude.txt D:\3rdPartySoftware\net-snmp\5.9.0\include D:\3rdPartySoftware\net-snmp\5.9.0\INSTALLATION_RELEASE\include\ & ^
      xcopy /S /Y D:\3rdPartySoftware\net-snmp\5.9.0\win32\net-snmp\net-snmp-config.h D:\3rdPartySoftware\net-snmp\5.9.0\INSTALLATION_RELEASE\include\net-snmp\ & ^
      xcopy /S /Y D:\3rdPartySoftware\net-snmp\5.9.0\win32\net-snmp\library\snmpv3-security-includes.h D:\3rdPartySoftware\net-snmp\5.9.0\INSTALLATION_RELEASE\include\net-snmp\library\ & ^
      xcopy /S /Y D:\3rdPartySoftware\net-snmp\5.9.0\win32\lib\release\netsnmp.lib D:\3rdPartySoftware\net-snmp\5.9.0\INSTALLATION_RELEASE\lib\


  7.  Final check... verify that the net-snmp-config.h (i.e. the settings net-snmp was built with) contain the 2 changes in the INSTALLATION_RELEASE/include directory
    1. Open file at path "D:\3rdPartySoftware\net-snmp\5.9.0\INSTALLATION_RELEASE\include\net-snmp\net-snmp-config.h"
    2. Search for __inline and HAVE_SETLOCALE and verify that they're as follows

  8. That's it! Now end-user applications (release build) should add
    1. Include path: D:\3rdPartySoftware\net-snmp\5.9.0\include D:\3rdPartySoftware\net-snmp\5.9.0\INSTALLATION_RELEASE\include
    2. Lib: D:\3rdPartySoftware\net-snmp\5.9.0\INSTALLATION_RELEASE\lib\netsnmp.lib

How To Install Net Snmp

Source: https://readthedocs.web.cern.ch/display/ICKB/Building+net-snmp+for+windows

Posted by: meadowsluch1979.blogspot.com

0 Response to "How To Install Net Snmp"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel