Win32 错误 LNK2019:无法解析的外部符号 [英] Win32 error LNK2019: unresolved external symbol

查看:54
本文介绍了Win32 错误 LNK2019:无法解析的外部符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试从 http://johnnie.jerrata.com/winsocktutorial/<学习 WinSock 编码/a> 但是当我编译我的监听套接字时,我得到 9 个 error LNK2019: unresolved external symbol 错误.它们看起来都与代码中使用的函数名称相同,在函数名称后面加上下划线前缀 referenced in function _WinMain@16

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.

什么是未解决的外部问题,我该如何解决?如果需要,我可以发布代码,但在该链接上都可见.我使用的是 Visual Studios 2010,Win32 项目.

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.

推荐答案

Unresolved external is linker error,告诉您您没有将符号链接到二进制文件中.

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

引用您链接的网站:

请随意下载整个教程代码清单.请记住,本教程中提供的任何代码都应该与 Winsock 库链接,通常是 wsock32.lib 或类似名称的东西.此外,在您自己的 IDE(Dev-C++、Microsoft VC++、C++ Builder 等)中使用教程中提供的代码时,请选择使用 WinMain() 构建 Windows 项目以避免错误.

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.

链接方法之一是:

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

另外,考虑使用 Boost.Asio原始 WinSock.

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

这篇关于Win32 错误 LNK2019:无法解析的外部符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆