Thread: Probably a simple problem

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    15

    Talking Probably a simple problem

    Greetings all i am leaving the world of C/C++ Console and learning Windows applications I am using Visual C/C++ 6.0
    My proplem is ive written a simple Hello World probram (follows) It will compile and excute with no problems at first but if I save the project and open it, it will still compile ok but it gives me Link errors (following) I appreciate any help this concern!! Thanks in advance

    Link errors are as follows

    Linking...
    LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
    Debug/Dgraphics2.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.

    Dgraphics2.exe - 2 error(s), 0 warning(s)

    Code is as follows

    #include <windows.h>
    #include <windowsx.h>
    #define win32_lean_and_mean

    int WINAPI WinMain (HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpcmdline,
    int ncmdshow)

    {

    MessageBox(NULL, "Whats up World!!",
    "My First Windows Program", 3);

    return(0);
    }

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Did you create the project for this program as a Win32 Application and not a Win32 Console Application?

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    15
    yes, I created it as a Win32 Application and added the c/c++ source file and it even runs fine as long as code it fresh but as soon as I save it and open the .cpp file, it will compile but it gives me link errors (posted in original message)

  4. #4
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,227
    go to project->settings->link, find in the bottom box where it says /subsystem:console and change it to /subsystem:windows

  5. #5
    Registered User
    Join Date
    Oct 2001
    Posts
    15

    Thumbs up

    That Worked!!!! I am forever in debted to you my fellow programmer again, Thanxs

    "To make an apple pie from scratch you must first create the Universe"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A simple file I/O problem
    By eecoder in forum C Programming
    Replies: 10
    Last Post: 10-16-2010, 11:00 PM
  2. Problem in simple code.
    By richdb in forum C Programming
    Replies: 6
    Last Post: 03-20-2006, 02:45 AM
  3. Problem in very simple code
    By richdb in forum C Programming
    Replies: 22
    Last Post: 01-14-2006, 09:10 PM
  4. Simple Initialization Problem
    By PsyK in forum C++ Programming
    Replies: 7
    Last Post: 04-30-2004, 07:37 PM
  5. Simple OO Problem
    By bstempi in forum C++ Programming
    Replies: 1
    Last Post: 04-30-2004, 05:33 PM