Windows.h not recognised

This is a discussion on Windows.h not recognised within the C++ Programming forums, part of the General Programming Boards category; I am going through a tutorial on DirectX and one continual problem is the windows.h file not being picked up ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,434
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  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をこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,422
    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, 09:18 AM
  5. Replies: 6
    Last Post: 01-07-2002, 01:46 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21