开发者

error LNK2028 when calling the WinSnmp function SnmpStartup?

开发者 https://www.devze.com 2023-03-18 20:33 出处:网络
I\'m trying to write a simple demo application in C++. I just want to query some of the printers on my network and sort the incoming info into a few database tables but I get this error when compiling

I'm trying to write a simple demo application in C++. I just want to query some of the printers on my network and sort the incoming info into a few database tables but I get this error when compiling my code:

Error 1 error LNK2028: unresolved token (0A00001C) "extern "C" unsigned long __stdcall SnmpCleanup(void)" (?SnmpCleanup@@$$J10YGKXZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) C:\Users\Ashton\Documents\Visual Studio 2010\Projects\snmpdemo\snmpdemo\Main.obj

My code is as follows:

//#include <Snmp.h>
#include <WinSnmp.h>
#include <stdio.h>

smiLPUINT32 majorVers;
smiL开发者_JAVA百科PUINT32 minorVers;
smiLPUINT32 nLevel;
smiLPUINT32 translateMode;
smiLPUINT32 retranslateMode;

int main()
{

    SnmpStartup(majorVers, minorVers, nLevel, translateMode, retranslateMode);

    printf("%imajorVers /n %iminorVers /n "
           "%inLevel /n "
           "%itranslateMode /n "
           "%iretranslateMode");

    SnmpCleanup();
}


You do not have any definition for SnmpStartup() & SnmpCleanup() so linker complains that it cannot find a reference to it. Probably, you are using a library which defines these functions but are you linking to it?

EDIT:

You should be linking your program to Wsnmp32.lib or Wsnmp32.dll and it should work fine.
Have a look at this.

0

精彩评论

暂无评论...
验证码 换一张
取 消