How To Use Net Snmp On Windows
Specifically, nosotros're talking
- Windows ten
- netsnmp v5.9.0
- Visual Studio v2017, customs edition - edifice static, release library (64 bit build)
Certain OPC-UA servers communicate with their target hardware using the SNMP protocol. For linux (centos7 distro anyway) edifice with SNMP is ~petty: basically adding -lnetsnmp. Windows is rather more involved. In club to accept the same netsnmp API between linux and windows servers, nosotros opted for the open source netsnmp, from netsnmp.org. Available as a binary build via regular yum repos for CentOS, only the library has to exist built by hand for windows. This document does not aim to replace, replace, or disagree with the fantabulous 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 afterward reading through README.win32.
The goal
- Start with download of the netsnmp source lawmaking archive.
- Build static release library + headers to provide netsnmp functionality, x64 build, visual studio 2017 community.
The steps
- Obtain source nada file from netsnmp.org and excerpt contents to D:\3rdPartySoftware\net-snmp\five.9.0
- Open x64 vcvars control prompt for VS2017 (note this step assumes perl already installed - if not install active perl, put on PATH etc) and check perl Configure works
- Configure build with following options; this generates files (header files only I call up) specific to this build
- EDIT file win32/cyberspace-snmp/net-snmp-config.h by mitt (earlier build)
- Remove redefinition of C++ keyword inline (net-snmp-config.h:1040).
- Explanation : if non, causes a VS2017 compile time mistake (redefinition of keyword)
- Explanation : if non, causes a VS2017 compile time mistake (redefinition of keyword)
- Undefine HAVE_SETLOCALE preprocessor macro ( net-snmp-config.h:664 ).
- Caption : fairly weird this 1. If non and then during init_snmp() API telephone call, the lawmaking will call setlocale(). Seems harmless enough, however, this function affects all graphic symbol functions (printf and friends). On windows, if office setlocale is chosen, LogIt's logging runtime operation (in this instance, LogIt is just a matter that pumps characters to parent powershell window) decreases by factor ~x. There is [this case on bitbucket.org]
- Caption : fairly weird this 1. If non and then during init_snmp() API telephone call, the lawmaking will call setlocale(). Seems harmless enough, however, this function affects all graphic symbol functions (printf and friends). On windows, if office setlocale is chosen, LogIt's logging runtime operation (in this instance, LogIt is just a matter that pumps characters to parent powershell window) decreases by factor ~x. There is [this case on bitbucket.org]
- Remove redefinition of C++ keyword inline (net-snmp-config.h:1040).
- Build library using nmake (from x64 vcvars cmd prompt). Note only building netsnmp library in this example (executables etc. non required) - Makefile target: libsnmp
- Install: The Configure options for install (--prefix, --destdir) don't seem to piece of work very well for static lib windows builds (*.lib missed, headers missing), so I manually 'installed' to directory INSTALLATION_RELEASE with a handmade script.
- Explanation : copies 'standard' netsnmp includes (excludes *.in files - only required during perl Configure step). And so copies some headers written during perl Configure step. Then copies static lib
And same command repeated below to allow for re-create paste of command
del exclude.txt & ^
echo .in >> exclude.txt & ^
rmdir /Due south /Q D:\3rdPartySoftware\net-snmp\5.9.0\INSTALLATION_RELEASE\include\ & ^
rmdir /Due south /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 /South /Y D:\3rdPartySoftware\net-snmp\v.nine.0\win32\net-snmp\net-snmp-config.h D:\3rdPartySoftware\net-snmp\v.9.0\INSTALLATION_RELEASE\include\net-snmp\ & ^
xcopy /Due south /Y D:\3rdPartySoftware\net-snmp\5.9.0\win32\net-snmp\library\snmpv3-security-includes.h D:\3rdPartySoftware\cyberspace-snmp\five.9.0\INSTALLATION_RELEASE\include\net-snmp\library\ & ^
xcopy /S /Y D:\3rdPartySoftware\net-snmp\five.nine.0\win32\lib\release\netsnmp.lib D:\3rdPartySoftware\net-snmp\5.9.0\INSTALLATION_RELEASE\lib\
- Explanation : copies 'standard' netsnmp includes (excludes *.in files - only required during perl Configure step). And so copies some headers written during perl Configure step. Then copies static lib
- Final check... verify that the net-snmp-config.h (i.e. the settings internet-snmp was congenital with) incorporate the two changes in the INSTALLATION_RELEASE/include directory
- Open file at path "D:\3rdPartySoftware\net-snmp\5.9.0\INSTALLATION_RELEASE\include\net-snmp\net-snmp-config.h"
-
Search for __inline and HAVE_SETLOCALE and verify that they're as follows
- That's it! At present stop-user applications (release build) should add
- Include path: D:\3rdPartySoftware\net-snmp\5.9.0\include D:\3rdPartySoftware\net-snmp\5.9.0\INSTALLATION_RELEASE\include
- Lib: D:\3rdPartySoftware\cyberspace-snmp\five.nine.0\INSTALLATION_RELEASE\lib\netsnmp.lib
Source: https://readthedocs.web.cern.ch/display/ICKB/Building+net-snmp+for+windows
Posted by: tateworactagoine.blogspot.com

0 Response to "How To Use Net Snmp On Windows"
Post a Comment