I'm new to VC++ and would like to know know how to link "wsock32.lib" within VC++. I'm trying to write a simple c++ server app and these are the error messages I'm getting. So how do I go about linking something in VC++?. Also is wsock32 the correct lib that I need?
1>------ Build started: Project: bla, Configuration: Debug Win32 ------
1>bla.obj : error LNK2019: unresolved external symbol _closesocket@4 referenced in function _main
1>bla.obj : error LNK2019: unresolved external symbol _send@16 referenced in function _main
1>bla.obj : error LNK2019: unresolved external symbol _recv@16 referenced in function _main
1>bla.obj : error LNK2019: unresolved external symbol _accept@12 referenced in function _main
1>bla.obj : error LNK2019: unresolved external symbol _listen@8 referenced in function _main
1>bla.obj : error LNK2019: unresolved external symbol _bind@12 referenced in function _main
1>bla.obj : error LNK2019: unresolved external symbol _socket@12 referenced in function _main
1>bla.obj : error LNK2019: unresolved external symbol _htons@4 referenced in function _main
1>bla.obj : error LNK2019: unresolved external symbol _WSAStartup@8 referenced in function _main
1>C:\Users\-r.s-\Desktop\bla\Debug\bla.exe : fatal error LNK1120: 9 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
You should link with "ws2_32.lib" library. Specify it in project settings or in source code via pragma directive:
#pragma comment(lib, "ws2_32.lib")
Addition: AFAIK Visual C++ Express does not includes Platform SDK, so if you can't find library on your computer you should download and install Platform SDK and add necessary folders in Visual Studio "VC++ Directories" property page.
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