Win32错误LNK2019:无法解析的外部符号(Win32 error LNK2019: unre

2019-10-31 20:14发布

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.

Answer 1:

未解决的外部是链接错误,告诉你,你没有链接你得到那些无法解析的外部符号为二进制。

从你链接的网站引用:

随意下载整个教程中的代码清单。 请记住,在本教程中的任何代码应与WinSock库链接,通常wsock32.lib或类似名称 。 此外,使用完全相同的代码时如在自己的IDE(开发-C ++,微软VC ++,C ++ Builder等)的教程中,选择建立一个WinMain函数Windows项目(),以避免错误。

其中一个方法来链接是:

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

此外,考虑使用Boost.Asio的 ,而不是原始的WinSock。



文章来源: Win32 error LNK2019: unresolved external symbol