永发信息网

net-snmp和Qt的问题[qmake和makefile]

答案:2  悬赏:10  手机版
解决时间 2021-01-29 18:15
  • 提问者网友:城市野鹿
  • 2021-01-29 04:41
我想用net-snmp做个网路管理,接着用qt做界面,结果单纯对net-snmp程序编译的时候用了自带的makefile 是没有问题的,但是后面要用到qt做界面,就想用qmake来生成makefile,但是就是报错,找不到头文件,我也在pro文件里面加入了头文件的路径,但是还是不行,有没有谁能帮我呢?

[root@localhost net-snmp]# qmake --version
QMake version 2.01a
Using Qt version 4.4.3 in /opt/EmbedSky/qt-4.5/__install/x86//lib
net-snmp是5.6.1的

net-snmp自带makefile如下:
-------------------------------------------
#
# Warning: you may need more libraries than are included here on the
# build line. The agent frequently needs various libraries in order
# to compile pieces of it, but is OS dependent and we can't list all
# the combinations here. Instead, look at the libraries that were
# used when linking the snmpd master agent and copy those to this
# file.
#

CC=gcc

OBJS1=snmpdemoapp.o
OBJS2=example-demon.o nstAgentSubagentObject.o
OBJS3=asyncapp.o
TARGETS=example-demon snmpdemoapp asyncapp

CFLAGS=-I. `net-snmp-config --cflags`
BUILDLIBS=`net-snmp-config --libs`
BUILDAGENTLIBS=`net-snmp-config --agent-libs`

# shared library flags (assumes gcc)
DLFLAGS=-fPIC -shared

all: $(TARGETS)

snmpdemoapp: $(OBJS1)
$(CC) -o snmpdemoapp $(OBJS1) $(BUILDLIBS)

asyncapp: $(OBJS3)
$(CC) -o asyncapp $(OBJS3) $(BUILDLIBS)

example-demon: $(OBJS2)
$(CC) -o example-demon $(OBJS2) $(BUILDAGENTLIBS)

clean:
rm $(OBJS2) $(OBJS2) $(TARGETS)

nstAgentPluginObject.so: nstAgentPluginObject.c Makefile
$(CC) $(CFLAGS) $(DLFLAGS) -c -o nstAgentPluginObject.o nstAgentPluginObject.c
$(CC) $(CFLAGS) $(DLFLAGS) -o nstAgentPluginObject.so nstAgentPluginObject.o
--------------------------------------------------------------------
我的pro文件如下:
--------------------------------------------------------------------
######################################################################
# Automatically generated by qmake (2.01a) ?? ?? 18 10:52:08 2011
######################################################################

TEMPLATE = app
TARGET =
DEPENDPATH += /usr/local/include/net-snmp
INCLUDEPATH += /usr/local/include
INCLUDEPATH += /usr/local/include/net-snmp
# Input
SOURCES += snmpdemoapp.c

谢谢了~~
最佳答案
  • 五星知识达人网友:街头电车
  • 2021-01-29 05:10
snmp的Makefile之后的话应该生成的是库,那么你只要把生成的库放在Qt工程文件夹下,然后在pro文件中LIBS += -l*** 、相关的头文件包含一下,(如直接把那几个头文件通过Qt Creator添加到工程里)应该就可以了。
全部回答
  • 1楼网友:西岸风
  • 2021-01-29 05:44
你好! 你的库文件不全,编译时引用提示出错。。 如果对你有帮助,望采纳。
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯