Thread: Windows.h not recognised

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    21

    Windows.h not recognised

    I am going through a tutorial on DirectX and one continual problem is the windows.h file not being picked up so I get 'unresolved externals' etc.. Presumably this header file should be in the C drive not created by the user, so do I just download something? Here is the code

    Code:
    #include <windows.h>
    
    int WINAPI WinMain(HINSTANCE hInstance,
                       HINSTANCE hPrevInstance,
                       LPSTR lpCmdLine,
                       int nShowCmd)
    {
        // create a "Hello World" message box using MessageBox()
        MessageBox(NULL,
                   L"Hello World!",
                   L"Just another Hello World program!",
                   MB_ICONEXCLAMATION | MB_OK);
    
        // return 0 to Windows
        return 0;
    }
    Should have said I am using VC++ 2008 Express edition.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    What exactly are your error messages?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Mar 2011
    Posts
    21
    1 errorLNK2019: unresolved external symbol_main referenced in function__tmainCRTStartup File MSVCRTD.lib
    RTD2 fatal error LNK1120: 1 unresolved externals File Test.exe

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Goto project properties -> Linker -> System. Set "Subsystem" to "Windows."
    In the future, select a Win32 project, and not a console project.
    Also, I suggest you upgrade to 2010.
    I also suggest you use a proper GUI library, such as Qt, instead of a pure Win32 approach.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User
    Join Date
    Mar 2011
    Posts
    21
    Excellent that worked. I'm not au fait with the difference between win32 and console programs, shows my inexperience in anything beyone plain console programming.

    I've heard of Qt as well and am trying to understand that.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C2061 errors : declaration not being recognised?
    By tritous in forum C Programming
    Replies: 4
    Last Post: 08-09-2009, 04:57 AM
  2. Open an excel file from a windows service under Windows Vista
    By AdrianaLuby in forum C# Programming
    Replies: 1
    Last Post: 06-05-2007, 03:55 AM
  3. Pointer member not being recognised properly
    By drrngrvy in forum C++ Programming
    Replies: 9
    Last Post: 10-02-2006, 02:15 PM
  4. ios_base functions not recognised in G++
    By Raison in forum C++ Programming
    Replies: 6
    Last Post: 03-09-2004, 10:18 AM
  5. Replies: 6
    Last Post: 01-07-2002, 02:46 AM