簡體   English   中英

C程序中的鏈接器錯誤

[英]Linker error in c program

我正在嘗試對使用Win32 api來顯示消息框的c程序進行編碼,但出現此鏈接器錯誤。 如何解決?

代碼:

#include<windows.h>

int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevsInstance,LPSTR SZCmdLine,int iCmdShow)
{
    MessageBox(NULL,TEXT("hello"),TEXT("this is me"),MB_ICONEXCLAMATION |  MB_OK);
   return 0;
}

錯誤:

1>------ Build started: Project: winfirstprog, Configuration: Debug Win32 ------
1>Compiling...
1>winfirstprog.cpp
1>Linking...
1>winfirstprog.obj : error LNK2028: unresolved token (0A000030) "extern "C" int __stdcall MessageBoxW(struct HWND__ *,wchar_t const *,wchar_t const *,unsigned int)" (?MessageBoxW@@$$J216YGHPAUHWND__@@PB_W1I@Z) referenced in function "extern "C" int __cdecl MessageBox(struct HWND__ *,wchar_t const *,wchar_t const *,unsigned int)" (?MessageBox@@$$J0YAHPAUHWND__@@PB_W1I@Z)
1>winfirstprog.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall MessageBoxW(struct HWND__ *,wchar_t const *,wchar_t const *,unsigned int)" (?MessageBoxW@@$$J216YGHPAUHWND__@@PB_W1I@Z) referenced in function "extern "C" int __cdecl MessageBox(struct HWND__ *,wchar_t const *,wchar_t const *,unsigned int)" (?MessageBox@@$$J0YAHPAUHWND__@@PB_W1I@Z)
1>F:\my_doc\C programming Prog & Documentation\Data structure in c\STARTOVER\winfirstprog\Debug\winfirstprog.exe : fatal error LNK1120: 2 unresolved externals
1>Build log was saved at "file://f:\my_doc\C programming Prog & Documentation\Data structure in c\STARTOVER\winfirstprog\winfirstprog\Debug\BuildLog.htm"
1>winfirstprog - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

正確的項目模板入門是99%的Hello World問題。 您沒有,該代碼是由C ++ / CLI編譯器編譯的。 File + New Project,然后選擇Win32 + Win32 Project模板。 –漢斯·帕桑(Hans Passant)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM