首页 > 解决方案 > 尝试在 C 中使用 Net-SNMP 时出现 LINK2019 错误

问题描述

因此,我尝试跟随 Net-SNMP 网站上的“snmpdemoapp”,尝试使用时出现 LINK2019 错误:

init_snmp("snmpdemoapp");

链接到演示应用程序:http://net-snmp.sourceforge.net/wiki/index.php/TUT: Simple_Application

如果我将此行注释掉,那么它将成功构建。我也在使用 Visual Studio 2015。我的参考资料中有 Net-SNMP 库。我也没有在“main()”函数中使用该库。

标签: cvisual-studio-2015snmpnet-snmp

解决方案


通过包括以下内容修复了错误:

#pragma comment(lib, "Ws2_32.lib")
#pragma comment(lib, "netsnmp.lib")
#pragma comment(lib, "netsnmpagent.lib")
#pragma comment(lib, "netsnmpmibs.lib")
#pragma comment(lib, "netsnmptrapd.lib")
#pragma comment(lib, "Advapi32.lib")

推荐阅读