Help with linking in Visual C++ Express
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>开发者_Go百科;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.
精彩评论