Win32 error LNK2019: unresolved external symbol

无人久伴 提交于 2019-12-25 04:18:12

问题


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

This also happens when I run the code example that is available for download, so I don't think I've made a mistake.

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.


回答1:


Unresolved external is linker error, telling you that you didn't link symbols you are getting those unresolved externals to into the binary.

Quoting from the site you linked:

Feel free to download the entire tutorial code listing. Remember that any code presented in this tutorial should be linked with the Winsock library, usually wsock32.lib or something similarly named. Also, when using code exactly as presented in the tutorial in your own IDE (Dev-C++, Microsoft VC++, C++ Builder, etc.), choose to build a Windows project with a WinMain() to avoid errors.

One of ways to link it is:

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

Also, consider using Boost.Asio instead of raw WinSock.



来源:https://stackoverflow.com/questions/11111344/win32-error-lnk2019-unresolved-external-symbol

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!