xx.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) 错误

本文介绍了一个在VS2010环境下使用他人提供的lib文件开发win32程序时遇到的编译错误,并给出了正确的解决方案。错误原因是使用了不匹配的lib版本(x64而非win32),通过更改lib版本并正确引入lib文件,问题得以解决。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在vs2010下用别人提供的lib开发win32程序,编译时出现:

Dummy.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: xxx@x@x@@x referenced in function _main

造成这种错误的原因百度出来一坨一坨的,结果自己这次是用错了lib文件的版本,应该用win32的,用成x64的了。改用win32后,就可以了。


当然,还有一个吾等菜鸟中的屌丝喜闻乐见的错误,就是没有正确引入lib文件。在vs2010的解决方法是:

1、添加lib所在目录到Project Preperty->Linker->General->Additional Library Directories下,绝对路径相对路径均可,或者将所用lib拷至编译目录下。

2、在Project Preperty->Linker->Input->Additional Dependencies中加入lib名称,或者在需要引入此lib的文件前边加上

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



在引用读卡器头文件时,会报错TransJoborderDlg.obj : error LNK2001: unresolved external symbol "int (__stdcall* TyA_CS_Write)(void *,unsigned char,unsigned char *)" (?TyA_CS_Write@@3P6GHPAXEPAE@ZA) TransJoborderDlg.obj : error LNK2001: unresolved external symbol "int (__stdcall* TyA_CS_Read)(void *,unsigned char,unsigned char *,unsigned char *)" (?TyA_CS_Read@@3P6GHPAXEPAE1@ZA) TransJoborderDlg.obj : error LNK2001: unresolved external symbol "int (__stdcall* TyA_CS_Authentication2)(void *,unsigned char,unsigned char,unsigned char *)" (?TyA_CS_Authentication2@@3P6GHPAXEEPAE@ZA) TransJoborderDlg.obj : error LNK2001: unresolved external symbol "int (__stdcall* TyA_Halt)(void *)" (?TyA_Halt@@3P6GHPAX@ZA) TransJoborderDlg.obj : error LNK2001: unresolved external symbol "int (__stdcall* TyA_Select)(void *,unsigned char *,unsigned char,unsigned char *)" (?TyA_Select@@3P6GHPAXPAEE1@ZA) TransJoborderDlg.obj : error LNK2001: unresolved external symbol "int (__stdcall* TyA_Anticollision)(void *,unsigned char,unsigned char *,unsigned char *)" (?TyA_Anticollision@@3P6GHPAXEPAE1@ZA) TransJoborderDlg.obj : error LNK2001: unresolved external symbol "int (__stdcall* TyA_Request)(void *,unsigned char,unsigned short *)" (?TyA_Request@@3P6GHPAXEPAG@ZA) TransJoborderDlg.obj : error LNK2001: unresolved external symbol "int (__stdcall* Sys_InitType)(void *,unsigned char)" (?Sys_InitType@@3P6GHPAXE@ZA) TransJoborderDlg.obj : error LNK2001: unresolved external symbol "int (__stdcall* Sys_SetAntenna)(void *,unsigned char)" (?Sys_SetAntenna@@3P6GHPAXE@ZA) TransJoborderDlg.obj : error LNK2001: unresolved external symbol "int (__stdcall* Sys_SetBuzzer)(void *,unsigned char)" (?Sys_SetBuzzer@@3P6GHPAXE@ZA) TransJoborderDlg.obj : error LNK2001: unresolved external symbol "int (__stdcall* Sys_SetLight)(void *,unsigned char)" (?Sys_SetLight@@3P6GHPAXE@ZA) TransJoborderDlg.obj : error LNK2001: unresolved external symbol "int (__stdcall* Sys_Close)(void * *)" (?Sys_Close@@3P6GHPAPAX@ZA) TransJoborderDlg.obj : error LNK2001: unresolved external symbol "int (__stdcall* Sys_IsOpen)(void *)" (?Sys_IsOpen@@3P6GHPAX@ZA) TransJoborderDlg.obj : error LNK2001: unresolved external symbol "int (__stdcall* Sys_Open)(void * *,unsigned long,unsigned short,unsigned short)" (?Sys_Open@@3P6GHPAPAXKGG@ZA) TransJoborderDlg.obj : error LNK2001: unresolved external symbol "int (__stdcall* Sys_GetHidSerialNumberStr)(unsigned long,unsigned short,unsigned short,char *,unsigned long)" (?Sys_GetHidSerialNumberStr@@3P6GHKGGPADK@ZA) TransJoborderDlg.obj : error LNK2001: unresolved external symbol "int (__stdcall* Sys_GetDeviceNum)(unsigned short,unsigned short,unsigned long *)" (?Sys_GetDeviceNum@@3P6GHGGPAK@ZA)这个如何解决
07-03
1>Misc.obj : error LNK2001: 无法解析的外部符号 "void __cdecl operator delete(void *,unsigned __int64)" (??3@YAXPEAX_K@Z) 21:13:14:191 1>AiManager.obj : error LNK2001: 无法解析的外部符号 "void __cdecl operator delete(void *,unsigned __int64)" (??3@YAXPEAX_K@Z) 21:13:14:191 1>CBuffManager.obj : error LNK2001: 无法解析的外部符号 "void __cdecl operator delete(void *,unsigned __int64)" (??3@YAXPEAX_K@Z) 21:13:14:191 1>CObject.obj : error LNK2001: 无法解析的外部符号 "void __cdecl operator delete(void *,unsigned __int64)" (??3@YAXPEAX_K@Z) 21:13:14:191 1>dllmain.obj : error LNK2001: 无法解析的外部符号 "void __cdecl operator delete(void *,unsigned __int64)" (??3@YAXPEAX_K@Z) 21:13:14:191 1>Misc.obj : error LNK2001: 无法解析的外部符号 atexit 21:13:14:191 1>ShellCode.obj : error LNK2001: 无法解析的外部符号 atexit 21:13:14:191 1>AiManager.obj : error LNK2001: 无法解析的外部符号 atexit 21:13:14:191 1>CBuffManager.obj : error LNK2001: 无法解析的外部符号 atexit 21:13:14:191 1>CObject.obj : error LNK2001: 无法解析的外部符号 atexit 21:13:14:191 1>dllmain.obj : error LNK2001: 无法解析的外部符号 atexit 21:13:14:191 1>CBuffManager.obj : error LNK2001: 无法解析的外部符号 _fltused 21:13:14:191 1>dllmain.obj : error LNK2001: 无法解析的外部符号 _fltused 21:13:14:203 1>Misc.obj : error LNK2001: 无法解析的外部符号 _fltused 21:13:14:203 1>Vector.obj : error LNK2001: 无法解析的外部符号 _fltused 21:13:14:203 1>dllmain.obj : error LNK2001: 无法解析的外部符号 "void * __cdecl operator new(unsigned __int64)" (??2@YAPEAX_K@Z) 21:13:14:203 1>dllmain.obj : error LNK2001: 无法解析的外部符号 "void * __cdecl operator new[](unsigned __int64)" (??_U@YAPEAX_K@Z) 21:13:14:203 1>ShellCode.obj : error LNK2001: 无法解析的外部符号 "void * __cdecl operator new[](unsigned __int64)" (??_U@YAPEAX_K@Z) 21:13:14:203 1>dllmain.obj : error LNK2001: 无法解析的外部符号 "void __cdecl operator delete[](void *)" (??_V@YAXPEAX@Z) 21:13:14:203 1>ShellCode.obj : error LNK2001: 无法解析的外部符号 "void __cdecl operator delete[](void *)" (??_V@YAXPEAX@Z) 21:13:14:203 1>dllmain.obj : error LNK2001: 无法解析的外部符号 _Init_thread_header 21:13:14:203 1>dllmain.obj : error LNK2001: 无法解析的外部符号 _Init_thread_footer 21:13:14:203 1>dllmain.obj : error LNK2001: 无法解析的外部符号 __imp_GetAsyncKeyState 21:13:14:203 1>dllmain.obj : error LNK2001: 无法解析的外部符号 __imp_GetForegroundWindow 21:13:14:203 1>dllmain.obj : error LNK2001: 无法解析的外部符号 "void __cdecl std::_Xlength_error(char const *)" (?_Xlength_error@std@@YAXPEBD@Z) 21:13:14:203 1>dllmain.obj : error LNK2001: 无法解析的外部符号 __chkstk 21:13:14:203 1>dllmain.obj : error LNK2001: 无法解析的外部符号 _Init_thread_epoch 21:13:14:203 1>dllmain.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) void (__cdecl* std::_Raise_handler)(class stdext::exception const &)" (__imp_?_Raise_handler@std@@3P6AXAEBVexception@stdext@@@ZEA) 21:13:14:203 1>dllmain.obj : error LNK2001: 无法解析的外部符号 "const type_info::`vftable'" (??_7type_info@@6B@) 21:13:14:203 1>dllmain.obj : error LNK2001: 无法解析的外部符号 _tls_index 21:13:14:203 1>D:\WeGameApps\英雄联盟\Game\hid.dll : fatal error LNK1120: 16 个无法解析的外部命令
最新发布
08-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值