MFC 静态链接未解析的外部符号

MFC Static Linking Unresolved External Symbol

本文关键字:外部 符号 静态 链接 MFC      更新时间:2023-10-16

我正在尝试使用Use of MFC: Use MFC in a Static Library构建GyazoWin的自定义版本,这导致了大量的引用错误。

如何安抚Visual Studio,以便我可以使用静态链接库进行构建?

更新

设法将 user32 添加到链接库中(我认为),现在我只有 1/3 的错误量。谁能说出我现在错过了哪个图书馆?

Error   2   error LNK2019: unresolved external symbol __imp__BitBlt@36 referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@YGJPAUHWND__@@IIJ@Z)  S:SoftwareMicrosoftVisual StudioProjectsCompleted (New)gyazowingyazowingyazowin.obj gyazowin
Error   3   error LNK2019: unresolved external symbol __imp__CreateCompatibleBitmap@12 referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@YGJPAUHWND__@@IIJ@Z)  S:SoftwareMicrosoftVisual StudioProjectsCompleted (New)gyazowingyazowingyazowin.obj gyazowin
Error   4   error LNK2019: unresolved external symbol __imp__CreateCompatibleDC@4 referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@YGJPAUHWND__@@IIJ@Z)   S:SoftwareMicrosoftVisual StudioProjectsCompleted (New)gyazowingyazowingyazowin.obj gyazowin
Error   5   error LNK2019: unresolved external symbol __imp__CreateFontW@56 referenced in function "long __stdcall LayerWndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?LayerWndProc@@YGJPAUHWND__@@IIJ@Z)   S:SoftwareMicrosoftVisual StudioProjectsCompleted (New)gyazowingyazowingyazowin.obj gyazowin
Error   6   error LNK2019: unresolved external symbol __imp__CreatePen@12 referenced in function "long __stdcall LayerWndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?LayerWndProc@@YGJPAUHWND__@@IIJ@Z) S:SoftwareMicrosoftVisual StudioProjectsCompleted (New)gyazowingyazowingyazowin.obj gyazowin
Error   7   error LNK2019: unresolved external symbol __imp__CreateSolidBrush@4 referenced in function "long __stdcall LayerWndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?LayerWndProc@@YGJPAUHWND__@@IIJ@Z)   S:SoftwareMicrosoftVisual StudioProjectsCompleted (New)gyazowingyazowingyazowin.obj gyazowin
Error   8   error LNK2019: unresolved external symbol __imp__DeleteDC@4 referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@YGJPAUHWND__@@IIJ@Z) S:SoftwareMicrosoftVisual StudioProjectsCompleted (New)gyazowingyazowingyazowin.obj gyazowin
Error   9   error LNK2019: unresolved external symbol __imp__DeleteObject@4 referenced in function "long __stdcall LayerWndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?LayerWndProc@@YGJPAUHWND__@@IIJ@Z)   S:SoftwareMicrosoftVisual StudioProjectsCompleted (New)gyazowingyazowingyazowin.obj gyazowin
Error   10  error LNK2019: unresolved external symbol __imp__GetDeviceCaps@8 referenced in function "long __stdcall LayerWndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?LayerWndProc@@YGJPAUHWND__@@IIJ@Z)  S:SoftwareMicrosoftVisual StudioProjectsCompleted (New)gyazowingyazowingyazowin.obj gyazowin
Error   11  error LNK2019: unresolved external symbol __imp__GetStockObject@4 referenced in function "unsigned short __cdecl MyRegisterClass(struct HINSTANCE__ *)" (?MyRegisterClass@@YAGPAUHINSTANCE__@@@Z)   S:SoftwareMicrosoftVisual StudioProjectsCompleted (New)gyazowingyazowingyazowin.obj gyazowin
Error   12  error LNK2019: unresolved external symbol __imp__Rectangle@20 referenced in function "long __stdcall LayerWndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?LayerWndProc@@YGJPAUHWND__@@IIJ@Z) S:SoftwareMicrosoftVisual StudioProjectsCompleted (New)gyazowingyazowingyazowin.obj gyazowin
Error   13  error LNK2019: unresolved external symbol __imp__SelectObject@8 referenced in function "long __stdcall LayerWndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?LayerWndProc@@YGJPAUHWND__@@IIJ@Z)   S:SoftwareMicrosoftVisual StudioProjectsCompleted (New)gyazowingyazowingyazowin.obj gyazowin
Error   14  error LNK2019: unresolved external symbol __imp__SetBkMode@8 referenced in function "long __stdcall LayerWndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?LayerWndProc@@YGJPAUHWND__@@IIJ@Z)  S:SoftwareMicrosoftVisual StudioProjectsCompleted (New)gyazowingyazowingyazowin.obj gyazowin
Error   15  error LNK2019: unresolved external symbol __imp__SetTextColor@8 referenced in function "long __stdcall LayerWndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?LayerWndProc@@YGJPAUHWND__@@IIJ@Z)   S:SoftwareMicrosoftVisual StudioProjectsCompleted (New)gyazowingyazowingyazowin.obj gyazowin
Error   16  error LNK2019: unresolved external symbol __imp__TextOutW@20 referenced in function "long __stdcall LayerWndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?LayerWndProc@@YGJPAUHWND__@@IIJ@Z)  S:SoftwareMicrosoftVisual StudioProjectsCompleted (New)gyazowingyazowingyazowin.obj gyazowin
Error   17  error LNK2019: unresolved external symbol __imp__ShellExecuteExW@4 referenced in function "void __cdecl execUrl(char const *)" (?execUrl@@YAXPBD@Z) S:SoftwareMicrosoftVisual StudioProjectsCompleted (New)gyazowingyazowingyazowin.obj gyazowin
Error   18  error LNK2019: unresolved external symbol __imp__SHGetSpecialFolderPathW@16 referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl getId(void)" (?getId@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) S:SoftwareMicrosoftVisual StudioProjectsCompleted (New)gyazowingyazowingyazowin.obj gyazowin
Error   19  error LNK1120: 17 unresolved externals  S:SoftwareMicrosoftVisual StudioProjectsCompleted (New)gyazowinDebuggyazowin.exe    gyazowin

对于平台库中的功能:

  1. 使用您喜欢的搜索引擎搜索函数的名称(例如"GetStockObject")。

  2. 在 MSDN 上查找该函数的文档(例如 GetStockObject)。 这通常是最重要的结果之一。

  3. 在文档中的"要求"下,找到"库"条目。 这是您必须链接才能使用该函数的库(对于GetStockObject,它是 gdi32.lib)。

  4. 重复此操作,直到解决完所有错误。