samedi 4 avril 2015

Net-SNMP Windows .lib Linking

I have downloaded net-snmp v5.7.3 onto a fresh OS (Windows 8) running Visual Studios 2010 with service pack 1 installed.


I am unable to create the following simple snmp project on the net-snmp website due to the inability to link to anything from their libraries.


They resulting build errors are as follows:



1>netsnmp.lib(system.obj) : error LNK2001: unresolved external symbol__imp__closesocket@4
1>netsnmp.lib(snmpUDPBaseDomain.obj) : error LNK2001: unresolved external symbol __imp__closesocket@4
1>netsnmp.lib(snmpSocketBaseDomain.obj) : error LNK2001: unresolved external symbol __imp__closesocket@4
1>netsnmp.lib(system.obj) : error LNK2001: unresolved external symbol __imp__getsockname@12
1>netsnmp.lib(snmpUDPBaseDomain.obj) : error LNK2001: unresolved external symbol __imp__getsockname@12
1>netsnmp.lib(snmpUDPIPv4BaseDomain.obj) : error LNK2001: unresolved external symbol __imp__getsockname@12
1>netsnmp.lib(system.obj) : error LNK2001: unresolved external symbol __imp__connect@12
1>netsnmp.lib(snmpTCPDomain.obj) : error LNK2001: unresolved external symbol __imp__connect@12
1>netsnmp.lib(system.obj) : error LNK2001: unresolved external symbol __imp__inet_addr@4
1>netsnmp.lib(snmp_api.obj) : error LNK2001: unresolved external symbol __imp__inet_addr@4
1>netsnmp.lib(read_config.obj) : error LNK2001: unresolved external symbol __imp__inet_addr@4
1>netsnmp.lib(system.obj) : error LNK2001: unresolved external symbol __imp__htons@4
1>netsnmp.lib(snmpTCPDomain.obj) : error LNK2001: unresolved external symbol __imp__htons@4
1>netsnmp.lib(snmpUDPDomain.obj) : error LNK2001: unresolved external symbol __imp__htons@4
1>netsnmp.lib(snmpIPv4BaseDomain.obj) : error LNK2001: unresolved external symbol __imp__htons@4
1>netsnmp.lib(system.obj) : error LNK2001: unresolved external symbol __imp__socket@12
1>netsnmp.lib(snmpTCPDomain.obj) : error LNK2001: unresolved external symbol __imp__socket@12
1>netsnmp.lib(snmpUDPBaseDomain.obj) : error LNK2001: unresolved external symbol __imp__socket@12
1>netsnmp.lib(snmpUDPIPv4BaseDomain.obj) : error LNK2001: unresolved external symbol __imp__socket@12
1>netsnmp.lib(system.obj) : error LNK2001: unresolved external symbol __imp__gethostbyname@4
1>netsnmp.lib(system.obj) : error LNK2001: unresolved external symbol __imp__gethostname@8
1>netsnmp.lib(snmpv3.obj) : error LNK2001: unresolved external symbol __imp__gethostname@8
1>netsnmp.lib(system.obj) : error LNK2001: unresolved external symbol __imp__RegCloseKey@4
1>netsnmp.lib(tools.obj) : error LNK2001: unresolved external symbol __imp__RegCloseKey@4
1>netsnmp.lib(system.obj) : error LNK2001: unresolved external symbol __imp__RegQueryValueExA@24
1>netsnmp.lib(tools.obj) : error LNK2001: unresolved external symbol __imp__RegQueryValueExA@24
1>netsnmp.lib(system.obj) : error LNK2001: unresolved external symbol __imp__WSAStartup@8
1>netsnmp.lib(system.obj) : error LNK2001: unresolved external symbol __imp__WSACleanup@0
1>netsnmp.lib(system.obj) : error LNK2001: unresolved external symbol __imp__gethostbyaddr@12
1>netsnmp.lib(snmp_api.obj) : error LNK2001: unresolved external symbol __imp__setsockopt@20
1>netsnmp.lib(snmpTCPDomain.obj) : error LNK2001: unresolved external symbol __imp__setsockopt@20
1>netsnmp.lib(snmpSocketBaseDomain.obj) : error LNK2001: unresolved external symbol __imp__setsockopt@20
1>netsnmp.lib(snmpUDPIPv4BaseDomain.obj) : error LNK2001: unresolved external symbol __imp__setsockopt@20
1>netsnmp.lib(snmpUDPDomain.obj) : error LNK2001: unresolved external symbol __imp__htonl@4
1>netsnmp.lib(snmpIPv4BaseDomain.obj) : error LNK2001: unresolved external symbol __imp__htonl@4
1>netsnmp.lib(inet_pton.obj) : error LNK2001: unresolved external symbol __imp__htonl@4
1>netsnmp.lib(mib.obj) : error LNK2001: unresolved external symbol __imp__htonl@4
1>netsnmp.lib(snmpusm.obj) : error LNK2001: unresolved external symbol __imp__htonl@4
1>netsnmp.lib(asn1.obj) : error LNK2001: unresolved external symbol __imp__htonl@4
1>netsnmp.lib(snmpv3.obj) : error LNK2001: unresolved external symbol __imp__htonl@4
1>netsnmp.lib(mib.obj) : error LNK2001: unresolved external symbol __imp__ntohl@4
1>netsnmp.lib(asn1.obj) : error LNK2001: unresolved external symbol __imp__ntohl@4
1>netsnmp.lib(snmp_client.obj) : error LNK2001: unresolved external symbol __imp__select@20
1>netsnmp.lib(callback.obj) : error LNK2001: unresolved external symbol __imp__select@20
1>netsnmp.lib(large_fd_set.obj) : error LNK2001: unresolved external symbol __imp__select@20
1>netsnmp.lib(snmp_logging.obj) : error LNK2001: unresolved external symbol __imp__ReportEventA@36
1>netsnmp.lib(snmp_logging.obj) : error LNK2001: unresolved external symbol __imp__CloseEventLog@4
1>netsnmp.lib(snmp_logging.obj) : error LNK2001: unresolved external symbol __imp__OpenEventLogA@8
1>netsnmp.lib(read_config.obj) : error LNK2001: unresolved external symbol __imp__inet_ntoa@4
1>netsnmp.lib(snmpUDPBaseDomain.obj) : error LNK2001: unresolved external symbol __imp__inet_ntoa@4
1>netsnmp.lib(snmpIPv4BaseDomain.obj) : error LNK2001: unresolved external symbol __imp__inet_ntoa@4
1>netsnmp.lib(tools.obj) : error LNK2001: unresolved external symbol __imp__RegOpenKeyExA@20
1>netsnmp.lib(snmpTCPDomain.obj) : error LNK2001: unresolved external symbol __imp__accept@12
1>netsnmp.lib(snmpTCPDomain.obj) : error LNK2001: unresolved external symbol __imp__listen@8
1>netsnmp.lib(snmpTCPDomain.obj) : error LNK2001: unresolved external symbol __imp__bind@12
1>netsnmp.lib(snmpUDPIPv4BaseDomain.obj) : error LNK2001: unresolved external symbol __imp__bind@12
1>netsnmp.lib(snmpTCPDomain.obj) : error LNK2001: unresolved external symbol __imp__ntohs@4
1>netsnmp.lib(snmpIPv4BaseDomain.obj) : error LNK2001: unresolved external symbol __imp__ntohs@4
1>netsnmp.lib(snmpUDPIPv4BaseDomain.obj) : error LNK2001: unresolved external symbol __imp__ntohs@4
1>netsnmp.lib(snmpUDPBaseDomain.obj) : error LNK2001: unresolved external symbol __imp__recvfrom@24
1>netsnmp.lib(snmpTCPBaseDomain.obj) : error LNK2001: unresolved external symbol __imp__recvfrom@24
1>netsnmp.lib(snmpUDPBaseDomain.obj) : error LNK2001: unresolved external symbol __imp__sendto@24
1>netsnmp.lib(snmpTCPBaseDomain.obj) : error LNK2001: unresolved external symbol __imp__sendto@24
1>netsnmp.lib(snmpUDPBaseDomain.obj) : error LNK2001: unresolved external symbol __imp__WSAGetLastError@0
1>netsnmp.lib(snmpUDPIPv4BaseDomain.obj) : error LNK2001: unresolved external symbol __imp__WSAGetLastError@0
1>netsnmp.lib(snmpUDPBaseDomain.obj) : error LNK2001: unresolved external symbol __imp__WSAIoctl@36
1>netsnmp.lib(snmpSocketBaseDomain.obj) : error LNK2001: unresolved external symbol __imp__getsockopt@20
1>netsnmp.lib(snmpSocketBaseDomain.obj) : error LNK2001: unresolved external symbol __imp__ioctlsocket@12


The build procedures I have followed are: (Active Perl x86 installed already)



  1. Open a cmd prompt with admin rights.

  2. C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat

  3. C:\net-snmp-5.7.3\win32\build.bat

  4. I enabled 'Install Development Files' and started the build.

  5. I created an empty project in VS and added the snmp code linked above.

  6. I added the include folder from the built PATH to the projects additional include directory.

  7. I added the lib folder from the built PATH to the projects additional library directories.

  8. I added netsnmp.lib to the additional library dependencies.


Additionally I have tried the above with x64 versions and had very similar, if not the same, build errors (I did not record them).


I also have tried updating the win32.dsw (from the win32 directory) to a VS2010 version and rebuilding the netsnmp.lib library before running build.bat. This did not change the build errors at all.


Side note: I also made a few quick fixes in net-snmp-config.h.



  • I included stdint.h because compiler was complaining I didn't have uint64_t.

  • I defined HAVE_SOCKLEN_T because compiler complained about a redefinition of socklen_t.

  • I added typedef int mode_t; because the compiler didn't like the import int mkdirhier(const char *pathname, mode_t mode, int skiplast).


I am sure I've overlooked something simple (maybe a required change to the config file), or am unaware of some correct procedure. So please, any advice will be considered helpful, no matter how small. I have limited knowledge with visual studios and snmp as I am only an engineering student currently working for a company under Co-op.


Aucun commentaire:

Enregistrer un commentaire