Jump to content
  • Advertisement
Sign in to follow this  
NeoMatrix2

windows.h?

This topic is 4886 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

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.

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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'.

Share this post


Link to post
Share on other sites
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

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!