newbie: unresolved reference to main - Programmer

This is a discussion on newbie: unresolved reference to main - Programmer ; Hi all, I'm a Unix programmer, new to MFC/C++, and especially the Visual Studio 2003 IDE. To add .cpp and .h files to my program I clicked: add new item | text file after all, .cpp and .h files are ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: newbie: unresolved reference to main

  1. newbie: unresolved reference to main

    Hi all,

    I'm a Unix programmer, new to MFC/C++, and especially the Visual Studio 2003
    IDE. To add .cpp and .h files to my program I clicked:

    add new item | text file

    after all, .cpp and .h files are text files) and then renamed the file from
    "TextFile1.txt" to "CMainFrame.cpp" or "MyWinApp.h".

    Bad move. Visual Studio does not recognize these as source or header files.
    I think VS thinks they're ordinary text files that aren't to be compiled.

    First thing is first:

    How can I change the status of these files from "textfile" to "source
    file" or "header file"? I'd rather not type all this by hand again.

    Second thing:

    What is the proper and most convenient way to create a blank .cpp or .h
    file with the name of my choosing?

    I've since found:

    File | New | File | C++ | Source File
    File | New | File | C++ | Header File

    which is completely unacceptable. If I really have to click a button just to
    start editing a cpp file, i want an 800x600 button, cenetered in the center
    of the screen, with red flashing letters that says "click me to add a new
    source file to your program".

    In addition, it names the file "source 1" and I have to click on "Save As" in
    order to rename the file.

    There must be a better way...

    Thanks!
    Pete

  2. Re: newbie: unresolved reference to main

    The problem is that you created the wrong kind of project. And then you created the wrong
    kind of files, requiring a renaming.

    When you are creating a Windows project, use the AppWizard to create a Win32 project, or
    better still, an MFC project. Do not "write everything by hand"; this is a waste of time
    and learning experience.

    When you add files, you must place them in the correct folder as source or header files
    On 29 Oct 2005 18:05:02 +0200, Pete wrote:

    >Hi all,
    >
    >I'm a Unix programmer, new to MFC/C++, and especially the Visual Studio 2003
    >IDE. To add .cpp and .h files to my program I clicked:
    >
    > add new item | text file
    >
    >after all, .cpp and .h files are text files) and then renamed the file from
    >"TextFile1.txt" to "CMainFrame.cpp" or "MyWinApp.h".
    >
    >Bad move. Visual Studio does not recognize these as source or header files.
    >I think VS thinks they're ordinary text files that aren't to be compiled.
    >
    >First thing is first:
    >
    > How can I change the status of these files from "textfile" to "source
    > file" or "header file"? I'd rather not type all this by hand again.
    >
    >Second thing:
    >
    > What is the proper and most convenient way to create a blank .cpp or .h
    > file with the name of my choosing?
    >
    >I've since found:
    >
    > File | New | File | C++ | Source File
    > File | New | File | C++ | Header File
    >
    >which is completely unacceptable. If I really have to click a button just to
    >start editing a cpp file, i want an 800x600 button, cenetered in the center
    >of the screen, with red flashing letters that says "click me to add a new
    >source file to your program".
    >
    >In addition, it names the file "source 1" and I have to click on "Save As" in
    >order to rename the file.
    >
    >There must be a better way...
    >
    >Thanks!
    >Pete

    Joseph M. Newcomer [MVP]
    email: newcomer@flounder.com
    Web: http://www.flounder.com
    MVP Tips: http://www.flounder.com/mvp_tips.htm

  3. Re: newbie: unresolved reference to main

    .... my control key stuck, so the "n" I typed became Ctrl+n. Grumble. It is too bad we
    can't buy reliable keyboards any longer; this one is less than three months old and the
    keys are going bad already...

    anyway, to resume:

    you must place the files in the correct project folder (this has nothing to do with
    folders which represent directories on the disk). Otherwise, they are not seen as files
    which are part of the project. Your error was in creating a text file; you should have
    created a "C/C++ source file" and a "C/C++ header file". Text files are not source files
    and therefore would not be automatically added to the project files.

    Many of us think the whole VS IDE sucks, and the editor in particular, and would never
    waste time with such a brain-dead editor. Therefore, we simply use our favorite
    programmer's editor (in my case, Lugaru's Epsilon) to create tthe files and then add them.
    You can create ;your own buttons if you want, but since the whole editor sucks, a lot of
    us just ignore its existence except for minor syntactic fixups such as repairing misplaced
    commas and dealing with too many/too few parentheses, and other trivial editing tasks.

    If ;you say the IDE sucks, join the crowd. A lot of us think it was designed by an
    amateur who once heard a description of an IDE over the phone, and the major failure at
    Microsoft was that his design was not laughed out of its first design review.

    The Better Way is to use a *real* editor, not the piece of crap Microsoft jokingly refers
    to as an editor.
    joe

    On 29 Oct 2005 18:05:02 +0200, Pete wrote:

    >Hi all,
    >
    >I'm a Unix programmer, new to MFC/C++, and especially the Visual Studio 2003
    >IDE. To add .cpp and .h files to my program I clicked:
    >
    > add new item | text file
    >
    >after all, .cpp and .h files are text files) and then renamed the file from
    >"TextFile1.txt" to "CMainFrame.cpp" or "MyWinApp.h".
    >
    >Bad move. Visual Studio does not recognize these as source or header files.
    >I think VS thinks they're ordinary text files that aren't to be compiled.
    >
    >First thing is first:
    >
    > How can I change the status of these files from "textfile" to "source
    > file" or "header file"? I'd rather not type all this by hand again.
    >
    >Second thing:
    >
    > What is the proper and most convenient way to create a blank .cpp or .h
    > file with the name of my choosing?
    >
    >I've since found:
    >
    > File | New | File | C++ | Source File
    > File | New | File | C++ | Header File
    >
    >which is completely unacceptable. If I really have to click a button just to
    >start editing a cpp file, i want an 800x600 button, cenetered in the center
    >of the screen, with red flashing letters that says "click me to add a new
    >source file to your program".
    >
    >In addition, it names the file "source 1" and I have to click on "Save As" in
    >order to rename the file.
    >
    >There must be a better way...
    >
    >Thanks!
    >Pete

    Joseph M. Newcomer [MVP]
    email: newcomer@flounder.com
    Web: http://www.flounder.com
    MVP Tips: http://www.flounder.com/mvp_tips.htm

  4. Re: newbie: unresolved reference to main


    I had posted my question as a "follow up" to another post. When I realized
    my mistake, I cancelled the post, intending to repost it. But before I had
    the chance to repost, my net connection went down. Argh!

    Anyhow, thanks for the responses, guys! I appreciate it. You restored my
    sanity! :-P

+ Reply to Thread