Hi, I'm currently trying to learn WinSock coding from http://johnnie.jerrata.com/winsocktutorial/ however when I compile my listening socket, I get 9 'error LNK2019: unresolved external symbol' errors. They all look to be the same function names that are used in the code prefixed with an underscore after the function name it says 'referenced in function _WinMain@16'

What is an unresolved external and how do I go about fixing one? I can post the code if needed but it's all visibile on that link. I'm using Visual Studios 2010, Win32 project.

Recommended Answers

All 3 Replies

You need to link the correct .lib/.dll/.a/.o files to your program.

#pragma comment('lib', "user32.dll"); Would be an example of doing so in Vs2010. I may have made a mistake doing the code above since I don't have access to a compiler to test atm, but it's something like that.

That will dynamically link user32.dll to your exe file. You can do winsock32.a or ws_s32.lib, etc.. Just make sure you link the correct files and your program will compile.

If you are using VS, then you can put this line at the very top of your source file:

#pragma comment(lib, "wsock32.lib")

Another option is to go into your project options menu and add the "wsock32.lib" to the list of external libraries to link to (amongst the list of all other external libraries, you'll see names like "kernel32.lib", "user32.lib", "gdi32.lib", etc., you just need to add "wsock32.lib" to that list).

Yeah I added wsock32.lib and all works fine, thanks a bunch

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.