链接器错误LNK2019从第三方库 [英] Linker error LNK2019 from 3rd party library
问题描述
我正在移植一个旧的vc ++ 6.0应用程序到vs2005,我得到以下链接器错误,我花了几天试图找到一个解决方案。
错误LNK2019:未解析的外部符号_ imp _CreateAwnService @ 52
引用函数public:int __thiscall
CMainFrame :: CreateAsaNetworkServices(void) p>
有一个第三方C库,定义了以下API
externC
{
DLLAPI IAwnServ * AWNAPI CreateAwnService(HINSTANCE hInst,
const char * pszDId,const char * pszDLoc,
AWN_DIQUAL DiQual, AWN_DOQUAL DoQual,int Prio,
const char * pszLicStr,const char * pszInfo,
AWN_REPEAT Repeat = R_LAST,TIME_T Since = 0,
BOOL bLogin = FALSE,BOOL bDeb = FALSE);
DLLAPI IAwnSend * AWNAPI CreateAwnSend(const IAwnSend * pSend = NULL);
DLLAPI IAwnData * AWNAPI CreateAwnData(const char * pData = NULL,int iLen = 0);
DLLAPI IAwnHeader * AWNAPI CreateAwnHeader(const IAwnHeader * pHeader = NULL);
DLLAPI IAwnReference * AWNAPI CreateAwnReference(const IAwnReference * pRef = NULL);
DLLAPI IAwnFile * AWNAPI CreateAwnFile(const char * pFile = NULL);
DLLAPI IAwnOrder * AWNAPI CreateAwnOrder(const IAwnOrder * pOrder);
DLLAPI IAwnVehicle * AWNAPI CreateAwnVehicle(const IAwnVehicle * pVehicle);
DLLAPI int AWNAPI AwnCmp(const IAwnSend * pSend1,const IAwnSend * pSend2);
DLLAPI TIME_T AWNAPI AwnGetNetTime(const char * NetTime);
DLLAPI int AWNAPI AwnSetNetTime(char * NetTime,TIME_T Time);
DLLAPI TIME_T AWNAPI AwnMakeQueryTime(int MonthsBack);
DLLAPI struct tm * AWNAPI AwnSplitTime(TIME_T Time);
DLLAPI TIME_T AWNAPI AwnMakeTime(tm * ptm);
}
#endif
如下:
m_pIAwnService = CreateAwnService(AfxGetApp() - > m_hInstance,.........)
我已检查所有链接包括等等,我似乎找不到错误。
任何帮助是非常感谢。
看起来你缺少导入库dll或链接器找不到它,在链接器 - >输入 - >其他依赖项
库路径可以在链接器 - >常规 - >附加库
可能是头文件尝试使用#pragma自动包含lib文件,因此您应该再次检查链接器是否可以找到该文件。 p>
另一件事要检查的是使用dependancy walker查看DLL,并确保你试图使用的函数真的是@ 52的堆栈清理大小。也许变量类型的大小在编译器版本之间发生了变化(例如typedefs)。
I am porting an old vc++6.0 application to vs2005, I am getting the following linker error and I have spent days trying to find a solution.
error LNK2019: unresolved external symbol _imp_CreateAwnService@52 referenced in function "public: int __thiscall CMainFrame::CreateAsaNetworkServices(void)"
There is a 3rd party C library with the following API defined
extern "C"
{
DLLAPI IAwnServ * AWNAPI CreateAwnService(HINSTANCE hInst,
const char *pszDId, const char *pszDLoc,
AWN_DIQUAL DiQual, AWN_DOQUAL DoQual, int Prio,
const char *pszLicStr, const char *pszInfo,
AWN_REPEAT Repeat=R_LAST, TIME_T Since=0,
BOOL bLogin=FALSE, BOOL bDeb=FALSE);
DLLAPI IAwnSend * AWNAPI CreateAwnSend(const IAwnSend *pSend = NULL);
DLLAPI IAwnData * AWNAPI CreateAwnData(const char *pData = NULL, int iLen = 0);
DLLAPI IAwnHeader * AWNAPI CreateAwnHeader(const IAwnHeader *pHeader = NULL);
DLLAPI IAwnReference * AWNAPI CreateAwnReference(const IAwnReference *pRef = NULL);
DLLAPI IAwnFile * AWNAPI CreateAwnFile(const char *pFile = NULL);
DLLAPI IAwnOrder * AWNAPI CreateAwnOrder( const IAwnOrder *pOrder);
DLLAPI IAwnVehicle * AWNAPI CreateAwnVehicle( const IAwnVehicle *pVehicle);
DLLAPI int AWNAPI AwnCmp( const IAwnSend *pSend1, const IAwnSend *pSend2);
DLLAPI TIME_T AWNAPI AwnGetNetTime( const char *NetTime);
DLLAPI int AWNAPI AwnSetNetTime( char *NetTime, TIME_T Time);
DLLAPI TIME_T AWNAPI AwnMakeQueryTime( int MonthsBack);
DLLAPI struct tm *AWNAPI AwnSplitTime( TIME_T Time);
DLLAPI TIME_T AWNAPI AwnMakeTime( tm *ptm);
}
#endif
The call to the API is as follows:
m_pIAwnService = CreateAwnService( AfxGetApp()->m_hInstance, .........)
I have checked all links includes etc and I cant seem to find the error.
Any help is much appreciated.
Looks like you're missing the import library for the dll, or the linker cannot find it, in the Linker -> Input -> Additional dependancies
The library paths can be set in Linker -> General -> Additional Library Directories
It may be that the header files try to automatically include the lib file using a #pragma, so you should again check that the linker can find the file.
Another thing to check would be to look at the DLL using dependancy walker and make sure the function you are trying to use really is @52 for the stack cleanup size. Perhaps the sizes of variable types have changed between the compiler versions (for e.g. the typedefs).
这篇关于链接器错误LNK2019从第三方库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!