如何处理链接器错误 [英] How to deal with linker errors

查看:118
本文介绍了如何处理链接器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Visual Studio 2013编译项目。该项目似乎是从早期版本的Visual Studio开发的。我已经解决了所有编译器错误,但现在有40个链接器错误。我是工作室的新手,没有
想法如何解决这些问题。

I am trying to compile a project using Visual Studio 2013. The project appears to have been developped from an earlier version of Visual Studio. I have solved all of the compiler errors but am now getting 40 linker errors. I am new to studio and have no idea how to solve these.

这只是所示4o错误的一个示例:



错误 4
错误LNK2019:未解析的外部符号__imp_accept在函数"public:virtual class CSimpleSocket * __cdecl CPassiveSocket :: Accept(void)"中引用(?接受@ CPassiveSocket @@ UEAAPEAVCSimpleSocket @@ XZ)
C:\Temp \ RSP_TCP \ ExtIO_RSP_TCP \ PassSocket.obj
ExtIO_RSP_TCP

错误 5
错误LNK2019:函数中引用的未解析的外部符号__imp_bind" public:bool __cdecl CPassiveSocket :: BindMulticast(char const *,char const *,unsigned short)" (?BindMulticast @ CPassiveSocket @@ QEAA_NPEBD0G @ Z)
C:\Temp \ RSP_TCP \ Extin_RSP_TCP \ PassassSocket.obj
ExtIO_RSP_TCP

错误 6
错误LNK2001:未解析的外部符号__imp_bind
C:\Temp \ RSP_TCP \\ \\ _ExtIO_RSP_TCP \SimpleSocket.obj
ExtIO_RSP_TCP

错误 7
错误LNK2019:未解析的外部符号__imp_getpeername在函数中引用"public:virtual class CSimpleSocket * __cdecl CPassiveSocket :: Accept(void) " (?接受@ CPassiveSocket @@ UEAAPEAVCSimpleSocket @@ XZ)
C:\Temp \ RSP_TCP \ ExtIO_RSP_TCP \ PassSocket.obj
ExtIO_RSP_TCP

错误 8
错误LNK2001:未解析的外部符号__imp_getpeername
C:\Temp \ RSP_TCP \ ExtIO_RSP_TCP \SimpleSocket.obj
ExtIO_RSP_TCP

错误 9
错误LNK2019:未解析的外部符号__imp_getsockname在函数"public:virtual class CSimpleSocket * __cdecl CPassiveSocket :: Accept(void)中引用)" (?接受@ CPassiveSocket @@ UEAAPEAVCSimpleSocket @@ XZ)
C:\Temp \ RSP_TCP \ ExtIO_RSP_TCP \ PassSocket.obj
ExtIO_RSP_TCP

错误 10
错误LNK2001:未解析的外部符号__imp_getsockname
C:\Temp \ RSP_TCP \ ExtIO_RSP_TCP \SimpleSocket.obj
ExtIO_RSP_TCP



这些错误是什么意思(什么是外部符号?)我该如何解决这些问题?

This is just a sample of the 4o errors shown:

Error 4 error LNK2019: unresolved external symbol __imp_accept referenced in function "public: virtual class CSimpleSocket * __cdecl CPassiveSocket::Accept(void)" (?Accept@CPassiveSocket@@UEAAPEAVCSimpleSocket@@XZ) C:\Temp\RSP_TCP\ExtIO_RSP_TCP\PassiveSocket.obj ExtIO_RSP_TCP
Error 5 error LNK2019: unresolved external symbol __imp_bind referenced in function "public: bool __cdecl CPassiveSocket::BindMulticast(char const *,char const *,unsigned short)" (?BindMulticast@CPassiveSocket@@QEAA_NPEBD0G@Z) C:\Temp\RSP_TCP\ExtIO_RSP_TCP\PassiveSocket.obj ExtIO_RSP_TCP
Error 6 error LNK2001: unresolved external symbol __imp_bind C:\Temp\RSP_TCP\ExtIO_RSP_TCP\SimpleSocket.obj ExtIO_RSP_TCP
Error 7 error LNK2019: unresolved external symbol __imp_getpeername referenced in function "public: virtual class CSimpleSocket * __cdecl CPassiveSocket::Accept(void)" (?Accept@CPassiveSocket@@UEAAPEAVCSimpleSocket@@XZ) C:\Temp\RSP_TCP\ExtIO_RSP_TCP\PassiveSocket.obj ExtIO_RSP_TCP
Error 8 error LNK2001: unresolved external symbol __imp_getpeername C:\Temp\RSP_TCP\ExtIO_RSP_TCP\SimpleSocket.obj ExtIO_RSP_TCP
Error 9 error LNK2019: unresolved external symbol __imp_getsockname referenced in function "public: virtual class CSimpleSocket * __cdecl CPassiveSocket::Accept(void)" (?Accept@CPassiveSocket@@UEAAPEAVCSimpleSocket@@XZ) C:\Temp\RSP_TCP\ExtIO_RSP_TCP\PassiveSocket.obj ExtIO_RSP_TCP
Error 10 error LNK2001: unresolved external symbol __imp_getsockname C:\Temp\RSP_TCP\ExtIO_RSP_TCP\SimpleSocket.obj ExtIO_RSP_TCP

What do these errors mean (what's an external symbol?) and what do I to solve these?

推荐答案

项目似乎没有为链接器提供Winsock2 dll的导入库作为输入。

It appears that the project is not providing the import library for the Winsock2 dll to the linker as input.

尝试将此添加到源代码文件 -

Try adding this to the source code file -

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


现在重建e项目。

Now rebuild the project.


这篇关于如何处理链接器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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