Roberto Viola

Qt, Net-SNMP and Windows: finally married!

Long story short: i was working on a SNMP client on Qt, talking with a Cisco Access Point. I’ve already a Qt software, so i decided to add the Net-SNMP library to my project.

These are the steps to achieve the result:

  1. Download the Net-SNMP library
  2. Extract it wherever you want
  3. Download MSYS and install it
  4. Run MSYS, you will have a bash shell
  5. Now, locate the mingw compiler on Qt (see the image below)
  6. On the MSYS bash type these commands:
    1. mkdir -p /mingw
    2. mount c:/Qt/Tools/mingw730_64 /mingw (the path of the mingw you discovered on point 5.)
    3. go to the Net-SNMP source path
    4. ./configure –prefix=/mingw –without-openssl –without-perl-modules
    5. make
    6. make install
  7. Now, in the mingw Qt dir, you should have the Net-SNMP library and tools.
  8. Edit your .pro files and add this line: win32: LIBS += -L$$PWD/net-snmp/lib/ -lnetsnmp -lws2_32
Locate the mingw compiler

Now you’re ready to build your project.

Some useful tips to remind:

  1. remember to setup the env variable MIBS, for example netsnmp_setenv(“MIBS”, “+AIRESPACE-WIRELESS-MIB”, 1);
  2. remember to specify the MIBS directories, for example netsnmp_set_mib_directory(QCoreApplication::applicationDirPath().toLatin1() + “/MIBS”);
  3. if you want to understand some problem, add these lines:

snmp_set_do_debugging(1);
snmp_enable_stderrlog ();
snmp_enable_calllog();
debug_register_tokens(“read_config,get_mib,parse”);

If you need support, don’t hesitate to add a comment below.