Prox" />

C++的error LNK2019: 无法解析的外部符号编译

1>Proxy.obj : error LNK2019: 无法解析的外部符号 __imp__connect@12,该符号在函数 "public: enum ProxyStatus __thiscall CProxy::ConnectProxyServer(unsigned int)" (?ConnectProxyServer@CProxy@@QAE?AW4ProxyStatus@@I@Z) 中被引用  
1>Proxy.obj : error LNK2019: 无法解析的外部符号 __imp__ioctlsocket@12,该符号在函数 "public: enum ProxyStatus __thiscall CProxy::ConnectProxyServer(unsigned int)" (?ConnectProxyServer@CProxy@@QAE?AW4ProxyStatus@@I@Z) 中被引用  
1>Proxy.obj : error LNK2019: 无法解析的外部符号 __imp__htons@4,该符号在函数 "public: enum ProxyStatus __thiscall CProxy::ConnectProxyServer(unsigned int)" (?ConnectProxyServer@CProxy@@QAE?AW4ProxyStatus@@I@Z) 中被引用  
1>Proxy.obj : error LNK2019: 无法解析的外部符号 __imp__inet_addr@4,该符号在函数 "private: enum ProxyStatus __thiscall CProxy::ConnectBySock4(unsigned int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,unsigned short)" (?ConnectBySock4@CProxy@@AAE?AW4ProxyStatus@@IV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@G@Z) 中被引用  
1>Proxy.obj : error LNK2019: 无法解析的外部符号 __imp__ntohs@4,该符号在函数 "private: enum ProxyStatus __thiscall CProxy::ConnectBySock4(unsigned int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,unsigned short)" (?ConnectBySock4@CProxy@@AAE?AW4ProxyStatus@@IV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@G@Z) 中被引用  
1>Proxy.obj : error LNK2019: 无法解析的外部符号 __imp__recv@16,该符号在函数 "private: int __thiscall CProxy::Receive(unsigned int,char *,int)" (?Receive@CProxy@@AAEHIPADH@Z) 中被引用  
1>Proxy.obj : error LNK2019: 无法解析的外部符号 __imp__select@20,该符号在函数 "public: enum ProxyStatus __thiscall CProxy::ConnectProxyServer(unsigned int)" (?ConnectProxyServer@CProxy@@QAE?AW4ProxyStatus@@I@Z) 中被引用  
1>Proxy.obj : error LNK2019: 无法解析的外部符号 __imp__send@16,该符号在函数 "private: bool __thiscall CProxy::Send(unsigned int,char const *,int)" (?Send@CProxy@@AAE_NIPBDH@Z) 中被引用  
1>Proxy.obj : error LNK2019: 无法解析的外部符号 __imp__setsockopt@20,该符号在函数 "public: enum ProxyStatus __thiscall CProxy::ConnectServer(unsigned int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,unsigned short)" (?ConnectServer@CProxy@@QAE?AW4ProxyStatus@@IV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@G@Z) 中被引用  
1>E:WorkVS2012SocketProxyDebugSocketProxy.exe : fatal error LNK1120: 9 个无法解析的外部命令  
1>  
1>生成失败。  

error LNK2019: 无法解析的外部符号  

出现这个错误一般都是函数只找到声明但没有实现,或者是少了什么链接库,可以试试把那两个.h和.c文件直接加入工程中再试试,或者是有些函数后面把{}加上。

比如一些函数声明了,像下面这段代码:

class A
{
public:
	A();
	virtual ~A();
	char m_x;
};

这里面构造函数和析构函数都没有加上{}。加上即可。

class A
{
public:
	A(){};
	virtual ~A(){};
	char m_x;
};

或者你另外实现这个函数。

还有种情况就是没有添加库

这种情况下加一句代码就行了

我遇到的是Socket相关的库没加上,我加上下面的部分就对了


#pragma comment(lib, "ws2_32.lib")  //这是链接API相关连的Ws2_32.lib静态库

一般加在stdafx.h里面就好了

如果出现这种情况就检查下有没有这玩意了

LINK : fatal error LNK1104: cannot open file "ws32_2.dll"

下面是地址,看看有没有

C:Program FilesMicrosoft Platform SDK for Windows Server 2003 R2BinWs2_32.dll

C:WINDOWSsystem32ws2_32.dll

C:WINDOWSsystem32dllcachews2_32.dll

文章导航