• Advertisement
Sign in to follow this  

Windows problems

This topic is 4552 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

#include <windows.h> int WINAPI Winmain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpcmdline,int nShowCmd) { MessageBox(NULL,"hi","hay",MB_OK|MB_ICONEXCLAMATION); } Compiler: Default compiler Building Makefile: "C:\Dev-Cpp\Makefile.win" Executing make... make.exe -f "C:\Dev-Cpp\Makefile.win" all g++.exe -c Untitled1.cpp -o Untitled1.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" g++.exe Untitled1.o -o "Project1.exe" -L"C:/Dev-Cpp/lib" lib/libmingw32.a lib/libmingw32.a(main.o)(.text+0x106):main.c: undefined reference to `WinMain@16' collect2: ld returned 1 exit status make.exe: *** [Project1.exe] Error 1 Execution terminated

Share this post


Link to post
Share on other sites
Advertisement
Do you have a function named "WinMain" or "main"? The linker is looking for "WinMain". I assume it works similarly to Visual Studio where you say you want a Windows app and you use WinMain, or you say you want a console app and you use main.

Share this post


Link to post
Share on other sites
Are you compiling it as a Windows program or a console program?

Edit: Darn it, beat by 2 seconds.

Share this post


Link to post
Share on other sites
Make sure that you have started the right type of project, namely a Win32 project not a Windows Console project. Each has a different 'main' function definition.

ace

EDIT: Completely thrashed, darn

Share this post


Link to post
Share on other sites
Now I don't get any errors ,but when I compile and run nothing happens
and when I try to run it nothing happens.

Share this post


Link to post
Share on other sites
C/C++ is case sensitive
It is correct to say it cannot find WinMain; as there is no function with that name defined
rename Winmain to WinMain

Share this post


Link to post
Share on other sites
Compiles and executes just fine here using both Dev-C++ 4.9.9.2 and Visual Studio .NET 2003. The code you have (minus simple typo) is fine. Did you try cleaning and rebuilding? Did you make any configuration changes in your Dev-C++ environment trying to get it to build when you had your linker error? If you generate a new Windows Application Project and immediately compile and run, does it work?

Just some things to think about.

Share this post


Link to post
Share on other sites
It doesn't work I don't know why the hell not ,but it doesn't.Its makes a sounds like tinng and nothing happens.

Share this post


Link to post
Share on other sites
Use this code it's your code just corrected.


#include <windows.h>
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpcmdline,int nShowCmd)
{
MessageBox(NULL,"hi","hay",MB_OK|MB_ICONEXCLAMATION);
return 0;
}




Fix your code and from the Execute menu choose rebuild all. Then when it is done rebuilding hit F9 to run it.

EDIT: Oops too late.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement