如果你在使用snmp++出现如下同样错误:这里住下看可以解决!
--------------------Configuration: tt - Win32 Debug--------------------
Linking...
tt.obj : error LNK2001: unresolved external symbol "public: class IpAddress & __thiscall IpAddress::operator=(char const *)" (??4IpAddress@@QAEAAV0@PBD@Z)
tt.obj : error LNK2001: unresolved external symbol "public: void __thiscall UdpAddress::set_port(unsigned short)" (?set_port@UdpAddress@@QAEXG@Z)
tt.obj : error LNK2001: unresolved external symbol "public: class UdpAddress & __thiscall UdpAddress::operator=(char const *)" (??4UdpAddress@@QAEAAV0@PBD@Z)
tt.obj : error LNK2001: unresolved external symbol "public: unsigned short __thiscall UdpAddress::get_port(void)const " (?get_port@UdpAddress@@QBEGXZ)
tt.obj : error LNK2001: unresolved external symbol "public: __thiscall UdpAddress::UdpAddress(char const *)" (??0UdpAddress@@QAE@PBD@Z)
tt.obj : error LNK2001: unresolved external symbol "public: __thiscall IpAddress::IpAddress(char const *)" (??0IpAddress@@QAE@PBD@Z)
tt.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall IpAddress::set_scope(unsigned int)" (?set_scope@IpAddress@@UAE_NI@Z)
tt.obj : error LNK2001: unresolved external symbol "public: virtual unsigned int __thiscall IpAddress::get_scope(void)const " (?get_scope@IpAddress@@UBEIXZ)
tt.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall IpAddress::map_to_ipv6(void)" (?map_to_ipv6@IpAddress@@UAEHXZ)
tt.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall IpAddress::format_output(void)const " (?format_output@IpAddress@@MBEXXZ)
tt.obj : error LNK2001: unresolved external symbol "protected: virtual bool __thiscall IpAddress::parse_address(char const *)" (?parse_address@IpAddress@@MAE_NPBD@Z)
tt.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall IpAddress::clear(void)" (?clear@IpAddress@@UAEXXZ)
tt.obj : error LNK2001: unresolved external symbol "public: virtual class SnmpSyntax & __thiscall IpAddress::operator=(class SnmpSyntax const &)" (??4IpAddress@@UAEAAVSnmpSyntax@@ABV1@@Z)
tt.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall Address::clear(void)" (?clear@Address@@MAEXXZ)
tt.obj : error LNK2001: unresolved external symbol "public: __thiscall IpAddress::IpAddress(class IpAddress const &)" (??0IpAddress@@QAE@ABV0@@Z)
tt.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall UdpAddress::set_scope(unsigned int)" (?set_scope@UdpAddress@@UAE_NI@Z)
tt.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall UdpAddress::map_to_ipv6(void)" (?map_to_ipv6@UdpAddress@@UAEHXZ)
tt.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall UdpAddress::format_output(void)const " (?format_output@UdpAddress@@MBEXXZ)
tt.obj : error LNK2001: unresolved external symbol "protected: virtual bool __thiscall UdpAddress::parse_address(char const *)" (?parse_address@UdpAddress@@MAE_NPBD@Z)
tt.obj : error LNK2001: unresolved external symbol "public: virtual class SnmpSyntax & __thiscall UdpAddress::operator=(class SnmpSyntax const &)" (??4UdpAddress@@UAEAAVSnmpSyntax@@ABV1@@Z)
tt.obj : error LNK2001: unresolved external symbol "public: __thiscall UdpAddress::UdpAddress(class UdpAddress const &)" (??0UdpAddress@@QAE@ABV0@@Z)
Debug/tt.exe : fatal error LNK1120: 21 unresolved externals
执行 link.exe 时出错.
tt.exe - 1 error(s), 0 warning(s)
参考这篇文档,SNMP++在VC6下的编辑和使用(三) 该文给出解决编译时出现问题解的办法即把snmp_pp.lib WS2_32.LIB加入到对象/库模块中(工程/设置/连接/常规),但给出的程序不完整,
#include "snmp_pp.h"
#include "iostream.h"
void main()
{
IpAddress ip("127.0.0.1");
cout<<"ip address is:"<<ip<<endl;
UdpAddress udp("127.0.0.1:8888");
cout<<"udp address is:"<<udp<<endl;
cout<<"udp address port is:"<<udp.get_port()<<endl;
udp="127.0.0.1";
udp.set_port(9999);
cout<<udp<<endl;
ip="258.0.0.1";
if(!ip.valid())
cout<<"bad ip:258.0.0.1"<<endl;
else
cout<<"good ip:258.0.0.1"<<endl;
ip="255.0.0.1";
if(!ip.valid())
cout<<"error ip:255.0.0.1"<<endl;
else
cout<<"good ip:255.0.0.1"<<endl;
ip="0.0.0.0";
if(!ip.valid())
cout<<"error ip:0.0.0.0"<<endl;
else
cout<<"good ip:0.0.0.0"<<endl;
ip="255.255.255.255";
if(!ip.valid())
cout<<"error ip:255.255.255.255"<<endl;
else
cout<<"good ip:255.255.255.255"<<endl;
}
至此你的问题已经解决。