SNMP++在VC6下的编辑和使用Word格式.docx
- 文档编号:923200
- 上传时间:2023-04-29
- 格式:DOCX
- 页数:16
- 大小:418.23KB
SNMP++在VC6下的编辑和使用Word格式.docx
《SNMP++在VC6下的编辑和使用Word格式.docx》由会员分享,可在线阅读,更多相关《SNMP++在VC6下的编辑和使用Word格式.docx(16页珍藏版)》请在冰点文库上搜索。
cpp文件
libdes
h和cpp文件
其中include目录包括以下内容
address.h
Addressclassesdefinitions
asn1.h
interfacesforASN1libraries
collect.h
Collectionclassdefinitions
counter.h
Counter32classdefinitions
ctr64.h
Counter64classdefinitions
eventlist.h
UXinternalimplementationsupportclass
gauge.h
Gauge32classdefinition
integer.h
Integer32classdefinition
ipresolv.h
msec.h
msgqueue.h
notifyqueue.h
octet.h
OctetStringclassdefinition
oid.h
Oidclassdefinition
oid_def.h
pdu.h
Pduclassdefinitions
smi.h
SMIdefinitions
smival.h
SnmpSyntaxclassdefinitions
snmp_pp.h
SNMP++mainheaderfile(alloneneedstoincludeisthis)
snmperrs.h
SNMP++errormessages
snmpmsg.h
SNMPMessageclassdefinition
target.h
SnmpTargetclass
timetick.h
TimeTicksclass
userdefined.h
UXinternalimplementationsupportclass
usertimeout.h
vb.h
VariableBindingclassdefinition
src目录包括以下内容
Makefile
makefileforHPUXbuild
address.cpp
Addressclasssource
asn1.cpp
ASN1encodinganddecodingcode.BasedonCMUcode.
collect.cpp
Collectionclasssource
counter.cpp
Counter32classsource
ctr64.cpp
Counter64classsource
eventlist.cpp
UXeventhandlersource
gauge.cpp
Gauge32classsource
integer.cpp
Integer32classsource
ipresolv.cpp
UXIpaddressresolversource
msec.cpp
msgqueue.cpp
notifyqueue.cpp
octet.cpp
OctetStringclasssource
oid.cpp
Oidclasssource
oidname.cpp
pdu.cpp
Pduclasssource
snmpmsg.cpp
SNMPMessageclasssource
target.cpp
SnmpTargetclasssource
test_app.cpp
testapplicationsource
timetick.cpp
TimeTicksclasssource
userdefined.cpp
usertimeout.cpp
uxsnmp.cpp
vb.cpp
VariableBindingclasssource
下面我们要在VC6中编辑生成snmp_pp.lib文件,操作步骤如下:
(1)在开发环境下,选择“File”->
“New…”项,在弹出的窗口中选择“Win32StaticLibrary”,工程名为“snmp_pp”,如图1所示。
图1
(2)单击“OK”按钮,进入下一步,使用缺省选项,如图2所示,点击“Finish”完成,建立一个没有文件的静态链接库工程。
图2
(3)在工作区内,为工程添加解压缩后的所有源文件(即snmp++目录下的src目录下的所有后缀为CPP的文件,如图3所示)
图3
为了让编译的链接库支持SNMPV3,要把snmp++目录下的libdes目录下的c文件包含进来,如图4所示
图4
用同样的方法,添加所有的头文件,如图5,图6所示
图5
图6
(4)文件添加完后,设置工程编译环境。
主菜单选“Project”->
“Settings…”项,弹出的窗口中,选“C/C++”页,按照下表进行设置,如图7所示
Category
CodeGeneration
Userun-timelibrary
DebugMultithreaded
图7
(5)目录设置。
主菜单“Tools”->
“Options…”项,弹出的窗口中,选“Directories”页,添加SNMP++头文件所在的目录(要强调一点,我们要做一点改动,即把snmp++\include目录下的所有H文件拷贝到snmp++目录),不只头文件所在的目录,还有包括CPP和C文件所在的目录及LIBDES这个目录),如图8所示
图8
(6)选择“Build”->
“Buildsnmp_pp.lib”项,生成静态链接库文件snmp_pp.lib。
(7)将生成的静态链接库文件直接复制到VC安装目录:
\VC98\Lib中去,就可以像使用VC自带的其他库文件一样使用它了。
下面就是SNMP++的使用了,以一个例子来说明,源代码如下:
#include
voidmain()
{
IpAddressip("
127.0.0.1"
);
cout<
<
"
ipaddressis:
UdpAddressudp("
127.0.0.1:
8888"
udpaddressis:
udpaddressportis:
ENDL;
udp="
;
udp.set_port(9999);
ip="
258.0.0.1"
if(!
ip.valid())
badip:
else
goodip:
255.0.0.1"
errorip:
0.0.0.0"
255.255.255.255"
FONT>
}
但是它在VC6中的编译还是有一些技巧的,我按顺序说一下:
(1)在VC中新建一个Win32Application的程序,命名为Cip,如图9所示
图9
(2)新建一个C++源文件,名为Cip,如图10所示
(3)把源代码贴进去
(4)试编译一次
会出一大堆这些的错:
--------------------Configuration:
Cip-Win32Debug--------------------
Compiling...
Cip.cpp
Linking...
Cip.obj:
errorLNK2001:
unresolvedexternalsymbol"
public:
classIpAddress&
__thiscallIpAddress:
:
operator=(charconst*)"
(?
?
4IpAddress@@QAEAAV0@PBD@Z)
void__thiscallUdpAddress:
set_port(unsignedshort)"
set_port@UdpAddress@@QAEXG@Z)
classUdpAddress&
__thiscallUdpAddress:
4UdpAddress@@QAEAAV0@PBD@Z)
unsignedshort__thiscallUdpAddress:
get_port(void)const"
get_port@UdpAddress@@QBEGXZ)
UdpAddress(charconst*)"
0UdpAddress@@QAE@PBD@Z)
IpAddress(charconst*)"
0IpAddress@@QAE@PBD@Z)
virtualint__thiscallIpAddress:
map_to_ipv6(void)"
map_to_ipv6@IpAddress@@UAEHXZ)
protected:
virtualvoid__thiscallIpAddress:
format_output(void)const"
format_output@IpAddress@@MBEXXZ)
virtualbool__thiscallIpAddress:
parse_address(charconst*)"
parse_address@IpAddress@@MAE_NPBD@Z)
clear(void)"
clear@IpAddress@@UAEXXZ)
virtualclassSnmpSyntax&
operator=(classSnmpSyntaxconst&
)"
4IpAddress@@UAEAAVSnmpSyntax@@ABV1@@Z)
virtualvoid__thiscallAddress:
clear@Address@@MAEXXZ)
IpAddress(classIpAddressconst&
0IpAddress@@QAE@ABV0@@Z)
virtualint__thiscallUdpAddress:
map_to_ipv6@UdpAddress@@UAEHXZ)
virtualvoid__thiscallUdpAddress:
format_output@UdpAddress@@MBEXXZ)
virtualbool__thiscallUdpAddress:
parse_address@UdpAddress@@MAE_NPBD@Z)
4UdpAddress@@UAEAAVSnmpSyntax@@ABV1@@Z)
UdpAddress(classUdpAddressconst&
0UdpAddress@@QAE@ABV0@@Z)
LIBCD.lib(wincrt0.obj):
unresolvedexternalsymbol_WinMain@16
Debug/Cip.exe:
fatalerrorLNK1120:
19unresolvedexternals
Errorexecutinglink.exe.
Cip.exe-20error(s),0warning(s)
其实是因为没有把snmp_pp.lib包括进去,把它加进去即可,如图11所示
这样执行“RebuildAll”命令后,只有9个错误了,如下所示:
Deletingintermediatefilesandoutputfilesforproject'
Cip-Win32Debug'
.
LINK:
warningLNK4098:
defaultlib"
LIBCMTD"
conflictswithuseofotherlibs;
use/NODEFAULTLIB:
library
snmp_pp.lib(address.obj):
unresolvedexternalsymbol_WSAGetLastError@0
unresolvedexternalsymbol_inet_ntoa@4
unresolvedexternalsymbol_gethostbyname@4
unresolvedexternalsymbol_gethostbyaddr@12
unresolvedexternalsymbol_inet_addr@4
unresolvedexternalsymbol_htons@4
unresolvedexternalsymbol_ntohs@4
fatalerro
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- SNMP VC6 编辑 使用