ボタンが押されたときにラベルに時間を表示するアプリで苦労した後、最終的にリンカー エラーに行き着きました。
これを引き起こしているコード行は次のとおりです。
_wstrdate(dateStr);
障害は次のとおりです。
error LNK2019: unresolved external symbol _wstrdate referenced in function "long __cdecl WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@YAJPAUHWND__@@IIJ@Z)
fatal error LNK1120: 1 unresolved externals
WNDPROC とリンカーの設定をここに投稿するように言われました。
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
static HWND hButton;
static HWND hLabel;
static SHACTIVATEINFO s_sai;
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_HELP_ABOUT:
DialogBox(g_hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, About);
break;
#ifdef WIN32_PLATFORM_PSPC
case IDM_OK:
SendMessage (hWnd, WM_CLOSE, 0, 0);
break;
case 1001:
{
_wstrdate(dateStr);
SetDlgItemTextW(hWnd, 1003, dateStr);
break;
}
#endif // WIN32_PLATFORM_PSPC
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_CREATE:
#ifdef SHELL_AYGSHELL
SHMENUBARINFO mbi;
memset(&mbi, 0, sizeof(SHMENUBARINFO));
mbi.cbSize = sizeof(SHMENUBARINFO);
mbi.hwndParent = hWnd;
mbi.nToolBarId = IDR_MENU;
mbi.hInstRes = g_hInst;
hButton = CreateWindow( L"button",L"Time",
WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,
100,200,
50,20,
hWnd, (HMENU) MEDDELANDEBUTTON_ID,
NULL, NULL);
hLabel = CreateWindowW(L"STATIC",L"Time",
WS_VISIBLE | WS_CHILD | SS_RIGHT,
10,200,75,35,hWnd, (HMENU)1003, NULL, NULL);
if (!SHCreateMenuBar(&mbi))
{
g_hWndMenuBar = NULL;
}
else
{
g_hWndMenuBar = mbi.hwndMB;
}
// Initialize the shell activate info structure
memset(&s_sai, 0, sizeof (s_sai));
s_sai.cbSize = sizeof (s_sai);
#endif // SHELL_AYGSHELL
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
#ifdef SHELL_AYGSHELL
CommandBar_Destroy(g_hWndMenuBar);
#endif // SHELL_AYGSHELL
PostQuitMessage(0);
break;
case WM_ACTIVATE:
// Notify shell of our activate message
SHHandleWMActivate(hWnd, wParam, lParam, &s_sai, FALSE);
break;
case WM_SETTINGCHANGE:
SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
また、ここに私のリンカーオプションがあります:(標準のvisualstudio 2008)
/OUT:"Pocket PC 2003 (ARMV4) \Debug/c++pocketpc.exe" /INCREMENTAL /NOLOGO /MANIFEST:NO /NODEFAULTLIB:"oldnames.lib" /DEBUG /PDB:"Pocket PC 2003 (ARMV4)\Debug/c++pocketpc.pdb" /STACK:65536,4096 /DYNAMICBASE:NO /ERRORREPORT:PROMPT coredll.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib