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?)
You need to link with Ws2_32.lib
See the MSDN documentation for ntohl, which says "Library: Ws2_32.lib".
I was also running into similar issues, and I was looking through project settings, linker settings, etc trying to figure out how to reference Ws2_32.lib and wondering why a Windows library wasn't linked through default settings in Visual studio.
I finally ran across this Windows article https://learn.microsoft.com/en-us/windows/win32/winsock/creating-a-basic-winsock-application and found that I could fix things through a pragma statement
#pragma comment(lib, "Ws2_32.lib")
Adding this to my header fixed the linking issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With