Search code examples
c++qtvisual-c++snmpnet-snmp

C++ Qt5 with net-snmp crashes after build


I am trying to use the http://www.net-snmp.org library in my project but after it build it crashes without the chance to get debug information.

To be more clear: I hit the run button -> Starting program.exe -> The program crashed without any output or window

I am using the Windows 7 64 bit, MSVC++ 2010 32 Bit compiler Qt5.0.2 and the binaries for net-snmp from http://softlayer-ams.dl.sourceforge.net/project/net-snmp/net-snmp%20binaries/5.7-binaries/net-snmp-5.7.0-1.x86.exe

I added these lines in my *.pro file to include the library

win32:INCLUDEPATH += "C:\snmp_5.7.0\include"
LIBS += -L"C:\snmp_5.7.0\lib" -lnetsnmp -lnetsnmpmibs -lnetsnmptrapd

and wanted to follow the "Simple application tutorial" (http://www.net-snmp.org/wiki/index.php/TUT:Simple_Application)

This is what I got so far:

snmpTest.h

#ifndef SNMPTEST_H
#define SNMPTEST_H

#include <QDebug>
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/library/transform_oids.h>

class SnmpTest
{
public:
    SnmpTest();
    void doSnmp();
};

#endif // SNMPTEST_H

snmpTest.cpp

#include "snmptest.h"

SnmpTest::SnmpTest()
{
}

void SnmpTest::doSnmp()
{
    const char *our_v3_passphrase = "XXXX";
    struct snmp_session session, *ss;
    struct snmp_pdu *pdu;
    struct snmp_pdu *response;

    oid anOID[MAX_OID_LEN];
    size_t anOID_len = MAX_OID_LEN;

    struct variable_list *vars;
    int status;

    /*
    * Initialize the SNMP library
    */
    init_snmp("app");

}

If I remove the line

init_snmp("app");

It builds and runs just fine.


Solution

  • I solved the problem by compiling the libary by myselfe