1
Win32 API를 사용하여 메시지 상자를 표시하는 C 프로그램을 코딩하려고하는데이 링커 오류가 발생합니다. 어떻게 해결 될 수 있습니까?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)" ([email protected]@[email protected]@[email protected]) referenced in function "extern "C" int __cdecl MessageBox(struct HWND__ *,wchar_t const *,wchar_t const *,unsigned int)" ([email protected]@[email protected]@[email protected])
1>winfirstprog.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall MessageBoxW(struct HWND__ *,wchar_t const *,wchar_t const *,unsigned int)" ([email protected]@[email protected]@[email protected]) referenced in function "extern "C" int __cdecl MessageBox(struct HWND__ *,wchar_t const *,wchar_t const *,unsigned int)" ([email protected]@[email protected]@[email protected])
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 ==========
후자는'MessageBox *()'를 구현하기 때문에 링커에게'User32.lib'을 링크하라고 할 수 있습니다. – alk
C++ 의도를 사용하고 있습니까? .cpp 파일을 VC로 전달하면 C++ 컴파일러로 실행됩니다. C++은 C와 다릅니다. – alk
올바른 프로젝트 템플릿 시작은 Hello World 문제의 99 %입니다. 당신은하지 않았다.이 코드는 C++/CLI 컴파일러에 의해 컴파일되었다. File + New Project를 선택하고 Win32 + Win32 Project 템플릿을 선택하십시오. –