Archived

This topic is now archived and is closed to further replies.

EbonySeraph

Windows API Problem

Recommended Posts

Alright. I am having trouble compiling(or linking) this simple windows program. All it does is open a window and process a close window message. //David Ogunsulire //firstwin.cpp //A minimal Windows 98 skeleton. #include LRESULT CALLBACK WindowFunc(HWND, UINT, WPARAM, LPARAM); char szWinName[] = "MyWin"; //Name of window class int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst, LPSTR lpszArgs, int nWinMode) { HWND hwnd; MSG msg; WNDCLASSEX wcl; //Define window class wcl.cbSize = sizeof(WNDCLASSEX); wcl.hInstance = hThisInst; //Handle to this instance wcl.lpszClassName = szWinName; //Window class name wcl.lpfnWndProc = WindowFunc; //Window function wcl.style = 0; //Default style wcl.hIcon = LoadIcon(NULL, IDI_APPLICATION); //Standard Icon wcl.hIconSm = LoadIcon(NULL, IDI_WINLOGO); //Small Icon wcl.hCursor = LoadCursor(NULL, IDC_ARROW); //Cursor style wcl.lpszMenuName = NULL; //No Menu wcl.cbClsExtra = 0; //No extra information wcl.cbWndExtra = 0; //No extra information // Make window background white wcl.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); // Register Window Class if(!RegisterClassEx(&wcl)) return 0; // Now that the window class has been resgistered, a window can be created hwnd = CreateWindow( //Parameter list szWinName, //Name of window class "Windows 98 Skeleton", //Title WS_OVERLAPPEDWINDOW, //Window style normal CW_USEDEFAULT, //X coordinate - Let Windows decide CW_USEDEFAULT, //Y coordinate - Let Windows decide CW_USEDEFAULT, //width - Let Windows decide CW_USEDEFAULT, //height - Let Windows decide HWND_DESKTOP, //No parent window NULL, //No menu hThisInst, //Handle of this instance of the program NULL //No additional arguments ); //Display the window ShowWindow(hwnd, nWinMode); UpdateWindow(hwnd); //Create the message loop while(GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); //Translate keyboard messages DispatchMessage(&msg); //Return control to Windows 98 } return msg.wParam; } //This function is called by Windows 98 and is passed messages from the mesage queue LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_DESTROY: //terminate program PostQuitMessage(0); break; default: //Let Windows 98 process any messages not specified //in this preceding switch statement return DefWindowProc(hwnd, message, wParam, lParam); } return 0; } Here is the error message: Info :Linking C:\Programs\WinC++\firstwin.exe Error: Error: Unresolved external ''_main'' referenced from C:\PROGRAMS\WINC++\C0X32.OBJ I am using Borland C++ 5.02. If I turn of the incremental linker the error is this: Info :Linking C:\Programs\WinC++\firstwin.exe Error: Error: Unresolved external ''_main'' referenced from module c0nt.ASM Under the error description for the first error(using incremental linker) the description is this: Unresolved external symbol referenced from module--- The named symbol is referenced in the given module but is not defined anywhere in the set of object files and libraries included in the link. Check to make sure the symbol is spelled correctly. You will usually see this error from the linker for C or C++ symbols if any of the following occur: You did not properly match a symbol’s declarations of __pascal and __cdecl types in different source files. You have omitted the name of an .OBJ file your program needs. You did not link in the emulation library. If you are linking C++ code with C modules, you might have forgotten to wrap C external declarations in extern “C”. You could also have a case mismatch between two symbols. Using Incremental linker the description is---- Unresolved external ''symbol'' referenced from module ''module'' Linker message The named symbol is referenced in the given module but is not defined anywhere in the set of object files and libraries included in the link. Check to make sure the symbol is spelled correctly. You will usually see this error from the linker for C or C++ symbols if any of the following occur: You did not properly match a symbol''s declarations of pascal and cdecl type in different source files. You have omitted the name of an .OBJ file your program needs. You did not link in the emulation library. If you are linking C++ code with C modules, you might have forgotten to wrap C external declarations in extern "C" {...}. You could also have a case mismatch between two symbols. And I didn''t mismatch the error descriptions - they dont lable the incrmental linker message. Thanks for the help. I dont think there is a syntax error or an error in the actually coding because I tried compiling the scource included in a book and it gave me the same error. The same errors occur using C and C++. Thanks for the help - and by the way, I am new to this boards, and I must say, IT ROCKS!!! Im only 14 so I am also also relatively new to programming.

Share this post


Link to post
Share on other sites
At the risk of ruining my image here, I will bump this post to the top. Im sorry, I really need an answer here or I simply can''t move foward.

Thanks in advance.

"Ogun''s Laughter Is No Joke!!!" - Ogun Kills On The Right, A Nigerian Poem.

Share this post


Link to post
Share on other sites
Hmm, it''s been a long while since I opened my copy of Borland 5.0... I''m assuming 5.02 uses the same IDE as 5.0. When you go to New->Project you get the "New Target" dialog. Here, set the combobox below the "Platform:" label to "Win32", and the "Target Model" to "GUI". That should do it. Just save the project somewhere, and include your code files in it.

[Resist Windows XP''s Invasive Production Activation Technology!]

Share this post


Link to post
Share on other sites
AHLELUIA!!!!!!!!!!!!!!!!!!!!(mispelled)

FINALLY AFTER HAVING THIS AWESOME BOOK FOR 2 WEEKS NOW I CAN FINNALY MAKE THESE PROGRAMS!!!!

Someone give Null and Void the Nobel Prize. Y'all appluad for him now!!!

I thousand kisses and thanks.

In, fact I am going to write down you name Null and Void so that when I become world reknown I will always mention what started it all. Its hard to find good help these days. If I write it book it will dedicated to the one the helped me.

"Ogun's Laughter Is No Joke!!!" - Ogun Kills On The Right, A Nigerian Poem.

Edited by - EbonySeraph on June 13, 2001 2:32:56 AM

Share this post


Link to post
Share on other sites