使用Qt Commercial(qmake + jom)崩溃编译的snmp-net库

时间:2013-02-08 13:27:54

标签: c++ qt snmp qmake

启动时应用程序崩溃(尝试调试和释放模式)。对此并不十分了解,我会感激任何帮助。

.pro文件

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = snmpTest5
TEMPLATE = app

LIBS += -LC:\snmp\lib -lnetsnmp -lnetsnmpagent  -lnetsnmpmibs
win32:INCLUDEPATH += "C:/snmp/include"

SOURCES += main.cpp\
        mainwindow.cpp

HEADERS  += mainwindow.h

FORMS    += mainwindow.ui

mainwindow.cpp

#include "mainwindow.h"
#include "ui_mainwindow.h"

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

#undef DEMO_USE_SNMP_VERSION_3

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_pushButton_clicked()
{
    netsnmp_session session, *ss;
    netsnmp_pdu *pdu;
    netsnmp_pdu *response;

    oid anOID[MAX_OID_LEN];
    size_t anOID_len;

    netsnmp_variable_list *vars;
    int status;
    int count=1;

    init_snmp("snmpdemoapp");
    snmp_sess_init( &session );
    session.peername = strdup("test.net-snmp.org");

    ui->textEdit->append("test");
}

应用程序输出

Starting ...\snmpTest5-build-Desktop_Qt_5_0_0_MSVC2010_32bit_SDK-Debug\debug\snmpTest5.exe...
The program has unexpectedly finished.
...\snmpTest5-build-Desktop_Qt_5_0_0_MSVC2010_32bit_SDK-Debug\debug\snmpTest5.exe exited with code -1073741515

编译输出

14:22:16: Running steps for project snmpTest5...
14:22:16: Starting: "C:\QtCommercial\QtCommercial5.0.0\5.0.0\msvc2010\bin\qmake.exe" ..\snmpTest5\snmpTest5.pro -r -spec win32-msvc2010
14:22:18: The process "C:\QtCommercial\QtCommercial5.0.0\5.0.0\msvc2010\bin\qmake.exe" exited normally.
14:22:18: Starting: "C:\QtCommercial\QtCommercial5.0.0\Tools\QtCreator\bin\jom.exe" 
    C:\QtCommercial\QtCommercial5.0.0\Tools\QtCreator\bin\jom.exe -f Makefile.Release
    C:\QtCommercial\QtCommercial5.0.0\5.0.0\msvc2010\bin\uic.exe ..\snmpTest5\mainwindow.ui -o ui_mainwindow.h
    cl -c -nologo -Zm200 -Zc:wchar_t -O2 -MD -GR -W3 -w34100 -w34189 -EHsc -DUNICODE -DWIN32 -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_OPENGL_ES_2 -DQT_OPENGL_ES_2_ANGLE -I"..\..\..\..\snmp\include" -I"..\..\..\..\QtCommercial\QtCommercial5.0.0\5.0.0\msvc2010\include" -I"..\..\..\..\QtCommercial\QtCommercial5.0.0\5.0.0\msvc2010\include\QtWidgets" -I"..\..\..\..\QtCommercial\QtCommercial5.0.0\5.0.0\msvc2010\include\QtGui" -I"..\..\..\..\QtCommercial\QtCommercial5.0.0\5.0.0\msvc2010\include\QtCore" -I"release" -I"." -I"." -I"..\..\..\..\QtCommercial\QtCommercial5.0.0\5.0.0\msvc2010\mkspecs\win32-msvc2010" -Forelease\ @C:\Users\Furby\AppData\Local\Temp\main.obj.4600.31.jom
    C:\QtCommercial\QtCommercial5.0.0\5.0.0\msvc2010\bin\moc.exe -DUNICODE -DWIN32 -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_OPENGL_ES_2 -DQT_OPENGL_ES_2_ANGLE -I"..\..\..\..\snmp\include" -I"..\..\..\..\QtCommercial\QtCommercial5.0.0\5.0.0\msvc2010\include" -I"..\..\..\..\QtCommercial\QtCommercial5.0.0\5.0.0\msvc2010\include\QtWidgets" -I"..\..\..\..\QtCommercial\QtCommercial5.0.0\5.0.0\msvc2010\include\QtGui" -I"..\..\..\..\QtCommercial\QtCommercial5.0.0\5.0.0\msvc2010\include\QtCore" -I"release" -I"." -I"." -I"..\..\..\..\QtCommercial\QtCommercial5.0.0\5.0.0\msvc2010\mkspecs\win32-msvc2010" -D_MSC_VER=1600 -DWIN32 ..\snmpTest5\mainwindow.h -o release\moc_mainwindow.cpp
    cl -c -nologo -Zm200 -Zc:wchar_t -O2 -MD -GR -W3 -w34100 -w34189 -EHsc -DUNICODE -DWIN32 -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_OPENGL_ES_2 -DQT_OPENGL_ES_2_ANGLE -I"..\..\..\..\snmp\include" -I"..\..\..\..\QtCommercial\QtCommercial5.0.0\5.0.0\msvc2010\include" -I"..\..\..\..\QtCommercial\QtCommercial5.0.0\5.0.0\msvc2010\include\QtWidgets" -I"..\..\..\..\QtCommercial\QtCommercial5.0.0\5.0.0\msvc2010\include\QtGui" -I"..\..\..\..\QtCommercial\QtCommercial5.0.0\5.0.0\msvc2010\include\QtCore" -I"release" -I"." -I"." -I"..\..\..\..\QtCommercial\QtCommercial5.0.0\5.0.0\msvc2010\mkspecs\win32-msvc2010" -Forelease\ @C:\Users\Furby\AppData\Local\Temp\mainwindow.obj.4600.124.jom
mainwindow.cpp
main.cpp
    cl -c -nologo -Zm200 -Zc:wchar_t -O2 -MD -GR -W3 -w34100 -w34189 -EHsc -DUNICODE -DWIN32 -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_OPENGL_ES_2 -DQT_OPENGL_ES_2_ANGLE -I"..\..\..\..\snmp\include" -I"..\..\..\..\QtCommercial\QtCommercial5.0.0\5.0.0\msvc2010\include" -I"..\..\..\..\QtCommercial\QtCommercial5.0.0\5.0.0\msvc2010\include\QtWidgets" -I"..\..\..\..\QtCommercial\QtCommercial5.0.0\5.0.0\msvc2010\include\QtGui" -I"..\..\..\..\QtCommercial\QtCommercial5.0.0\5.0.0\msvc2010\include\QtCore" -I"release" -I"." -I"." -I"..\..\..\..\QtCommercial\QtCommercial5.0.0\5.0.0\msvc2010\mkspecs\win32-msvc2010" -Forelease\ @C:\Users\Furby\AppData\Local\Temp\moc_mainwindow.obj.4600.312.jom
moc_mainwindow.cpp
..\snmpTest5\mainwindow.cpp(36) : warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details.
        C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\string.h(238) : see declaration of 'strdup'
..\snmpTest5\mainwindow.cpp(32) : warning C4189: 'count' : local variable is initialized but not referenced
..\snmpTest5\mainwindow.cpp(25) : warning C4101: 'response' : unreferenced local variable
..\snmpTest5\mainwindow.cpp(28) : warning C4101: 'anOID_len' : unreferenced local variable
..\snmpTest5\mainwindow.cpp(27) : warning C4101: 'anOID' : unreferenced local variable
..\snmpTest5\mainwindow.cpp(31) : warning C4101: 'status' : unreferenced local variable
..\snmpTest5\mainwindow.cpp(24) : warning C4101: 'pdu' : unreferenced local variable
..\snmpTest5\mainwindow.cpp(23) : warning C4101: 'ss' : unreferenced local variable
..\snmpTest5\mainwindow.cpp(30) : warning C4101: 'vars' : unreferenced local variable
    link /NOLOGO /DYNAMICBASE /NXCOMPAT /INCREMENTAL:NO /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST /MANIFESTFILE:release\snmpTest5.exe.embed.manifest /OUT:release\snmpTest5.exe @C:\Users\Furby\AppData\Local\Temp\snmpTest5.exe.4600.2979.jom
    mt.exe /nologo /manifest release\snmpTest5.exe.embed.manifest /outputresource:release\snmpTest5.exe;1
14:22:28: The process "C:\QtCommercial\QtCommercial5.0.0\Tools\QtCreator\bin\jom.exe" exited normally.

提前致谢。

1 个答案:

答案 0 :(得分:1)

也许您已经设置了共享库路径。如果所需的库不在PATH(在windows中)环境变量或LD_LIBRARY_PATH(在linux中)或DYLD_LIBRARY_PATH(在Mac osx中 - 不鼓励使用,但不用于开发),应用程序将无法在Qt Creator中加载,而无需通知。{{ 3}})

要在Windows中进行测试:

检查是否可以从命令行运行\ snmpTest5.exe。如果没有,请使用命令提示符:

设置PATH =%PATH%,

然后再次运行: \ snmpTest5.exe