windows.h?
okay i recently loaned "openGL game programming" from my library because i never buy books if i dont have to. sumtimes they are very bad and i save wasting my money. this book however i cant review yet because i cant even start it! its not too clearly layed out... it says first lets dicuss the hello world program i type it in "windows.h could not b found whilst compiling", i try the full program with #defines and includes and that cudnt find windows.h ? i tried in both visual studio and sharpdevelop the free IDE. whts going on here? are these console or win32 apps coz it dont work in either and where is <windows.h>?
normal code like hello world with iostream etc works, all libs includes are set i know that. where do i type this books code? i have all sdk's and etc installed all blady bah but still no such file or directory as windows.h...and the book doesnt even explain where and how to type it gives 3 total different version of same code not stating which i wil b using.
this is a book extrcat just to show from the book.
//Hello world program
#include <stdio.h>
void main()
{
printf("hello world\n");
}
youre now going to take this dos based program and convert to windows style
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
MessageBox(NULL, "\tHello World!", "My First Windows Application", NULL);
return 0;
}
thats it probably ur simplest program youll ever see.
--------------------Configuration: hello - Win32 Debug--------------------
Compiling...
s.cpp
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/hello.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
hello.exe - 2 error(s), 0 warning(s)
now the top part works whether i do iostream or stdio.h but not the 2nd part. all i do is create empty project, add a source file paste that execute and no go.
//Hello world program
#include <stdio.h>
void main()
{
printf("hello world\n");
}
youre now going to take this dos based program and convert to windows style
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
MessageBox(NULL, "\tHello World!", "My First Windows Application", NULL);
return 0;
}
thats it probably ur simplest program youll ever see.
--------------------Configuration: hello - Win32 Debug--------------------
Compiling...
s.cpp
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/hello.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
hello.exe - 2 error(s), 0 warning(s)
now the top part works whether i do iostream or stdio.h but not the 2nd part. all i do is create empty project, add a source file paste that execute and no go.
Quote:where is <windows.h>?
Normally, in the include directory where you installed you IDE. Make sure it's listed in the include directories of your compiler.
okay i just looked al files acounted for in vc98\include hence no more cant find windows.h thing but what do those errors mean?
im using visual c++ 6.0
im using visual c++ 6.0
Quote:Original post by NeoMatrix2
this is a book extrcat just to show from the book.
//Hello world program
#include <stdio.h>
void main()
{
printf("hello world\n");
}
youre now going to take this dos based program and convert to windows style
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
MessageBox(NULL, "\tHello World!", "My First Windows Application", NULL);
return 0;
}
thats it probably ur simplest program youll ever see.
--------------------Configuration: hello - Win32 Debug--------------------
Compiling...
s.cpp
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/hello.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
hello.exe - 2 error(s), 0 warning(s)
now the top part works whether i do iostream or stdio.h but not the 2nd part. all i do is create empty project, add a source file paste that execute and no go.
That error is not caused by not finding windows.h. It is caused by creating a Console application instead of a Win32 application. When you create a Console application, the linker expects to find the function 'main'. With a Win32 application, it looks for 'WinMain'.
YES! it works :D thanx ever so much all of you.
just thought id share as to the order of what was happening!
i had vb includes set up so no windows.h found.....then i set up vc includes too and it gave me those errors! still thinkin .h missing, then i used console coz of first example instead of win32 and message box just popped up all working :D thanx every1
just thought id share as to the order of what was happening!
i had vb includes set up so no windows.h found.....then i set up vc includes too and it gave me those errors! still thinkin .h missing, then i used console coz of first example instead of win32 and message box just popped up all working :D thanx every1
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement