简体   繁体   中英

MFC Static Linking Unresolved External Symbol

I am trying to build a custom version of GyazoWin using Use of MFC: Use MFC in a Static Library , and it results in a huge list of reference errors.

How can I appease Visual Studio so I can build using static linked libraries?

Update

I managed to add user32 to the linked libraries (I think) and now I only have 1/3rd the amount of errors. Can anyone tell what library I'm missing now?

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:\Software\Microsoft\Visual Studio\Projects\Completed (New)\gyazowin\gyazowin\gyazowin.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:\Software\Microsoft\Visual Studio\Projects\Completed (New)\gyazowin\gyazowin\gyazowin.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:\Software\Microsoft\Visual Studio\Projects\Completed (New)\gyazowin\gyazowin\gyazowin.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:\Software\Microsoft\Visual Studio\Projects\Completed (New)\gyazowin\gyazowin\gyazowin.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:\Software\Microsoft\Visual Studio\Projects\Completed (New)\gyazowin\gyazowin\gyazowin.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:\Software\Microsoft\Visual Studio\Projects\Completed (New)\gyazowin\gyazowin\gyazowin.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:\Software\Microsoft\Visual Studio\Projects\Completed (New)\gyazowin\gyazowin\gyazowin.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:\Software\Microsoft\Visual Studio\Projects\Completed (New)\gyazowin\gyazowin\gyazowin.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:\Software\Microsoft\Visual Studio\Projects\Completed (New)\gyazowin\gyazowin\gyazowin.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:\Software\Microsoft\Visual Studio\Projects\Completed (New)\gyazowin\gyazowin\gyazowin.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:\Software\Microsoft\Visual Studio\Projects\Completed (New)\gyazowin\gyazowin\gyazowin.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:\Software\Microsoft\Visual Studio\Projects\Completed (New)\gyazowin\gyazowin\gyazowin.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:\Software\Microsoft\Visual Studio\Projects\Completed (New)\gyazowin\gyazowin\gyazowin.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:\Software\Microsoft\Visual Studio\Projects\Completed (New)\gyazowin\gyazowin\gyazowin.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:\Software\Microsoft\Visual Studio\Projects\Completed (New)\gyazowin\gyazowin\gyazowin.obj gyazowin
Error   17  error LNK2019: unresolved external symbol __imp__ShellExecuteExW@4 referenced in function "void __cdecl execUrl(char const *)" (?execUrl@@YAXPBD@Z) S:\Software\Microsoft\Visual Studio\Projects\Completed (New)\gyazowin\gyazowin\gyazowin.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:\Software\Microsoft\Visual Studio\Projects\Completed (New)\gyazowin\gyazowin\gyazowin.obj gyazowin
Error   19  error LNK1120: 17 unresolved externals  S:\Software\Microsoft\Visual Studio\Projects\Completed (New)\gyazowin\Debug\gyazowin.exe    gyazowin

For functionality from platform libraries:

  1. Do a search for the name of the function (eg "GetStockObject") using your favorite search engine.

  2. Find the documentation for the function on MSDN (eg GetStockObject ). It'll usually be one of the top results.

  3. In the documentation, under "Requirements," find the "Library" entry. That is the library with which you must link to use the function (for GetStockObject , it's gdi32.lib).

  4. Repeat until you've resolved all of the errors.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM