Windows problems
#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
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.
Are you compiling it as a Windows program or a console program?
Edit: Darn it, beat by 2 seconds.
Edit: Darn it, beat by 2 seconds.
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
ace
EDIT: Completely thrashed, darn
Now I don't get any errors ,but when I compile and run nothing happens
and when I try to run it nothing happens.
and when I try to run it nothing happens.
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
It is correct to say it cannot find WinMain; as there is no function with that name defined
rename Winmain to WinMain
I know I fixed that ,but now when I click on it doesn't open.Or maybe it opens and closes.Not sure.
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.
Just some things to think about.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement