Problem linking basic MFC project

Cyrilix

2[H]4U
Joined
Jan 21, 2005
Messages
2,188
The code is the following, and gives me a linker error telling me to define the entry point. I thought MFC automatically defined InitInstance() as the entry point (I am new to this). I am currently trying to compile/link within Visual Studio 2007 Beta 1.

Code:
#include <afxwin.h>

class MFC_Tutorial_Window : public CFrameWnd
{
public:
    MFC_Tutorial_Window()
    {
        Create(NULL, "MFC Tutorial Part 1 CoderSource Window");
    }
};

class MyApp : public CWinApp
{
public:
    BOOL InitInstance()
    {
        wnd = new MFC_Tutorial_Window();
        m_pMainWnd = wnd;
        m_pMainWnd->ShowWindow(1);
        return 1;
    }

    MFC_Tutorial_Window *wnd; 
};

MyApp theApp;
 
You don't give too many details, so I'm forced to either ask a long list of clarifying questions, or guess.

Let's try guessing. MFC does automatically define the program's entry point, but it is not InitInstance(). For a Windows application, the entry point is WinMain(). For a console application, the entry point is main(). My guess is that you're writing a windows application, but telling the linker you've got /SUBSYSTEM:CONSOLE, and it's looking for ___tmainCRTStartup, instead.
 
You don't give too many details, so I'm forced to either ask a long list of clarifying questions, or guess.

Let's try guessing. MFC does automatically define the program's entry point, but it is not InitInstance(). For a Windows application, the entry point is WinMain(). For a console application, the entry point is main(). My guess is that you're writing a windows application, but telling the linker you've got /SUBSYSTEM:CONSOLE, and it's looking for ___tmainCRTStartup, instead.

I had a hunch that would be the problem, but I'm trying to find that specific option in VS 2007 Beta 1 and I don't see it at all, so I'll keep looking...

Edit: NVM, found it, and that does indeed fix the issue -- you guessed correctly. :)

Thanks.
 
Back
Top