Search code examples
c++windowslinkerwinsock

C function **ntohl** gives linker error (unresolved externals)


The function ntohl gives a linker error for me:

error LNK2001: unresolved external symbol _ntohl@4
fatal error LNK1120: 1 unresolved externals

I have included

#include <winsock.h>

Is there a specific reason for that? (or can this function be easyly done manually?)


Solution

  • You need to link with Ws2_32.lib

    See the MSDN documentation for ntohl, which says "Library: Ws2_32.lib".