0

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.

3
Contributors
3
Replies
5
Views
5 Years
Discussion Span
Last Post by benikens
0

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.

1

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).

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.