0

I've downloaded and compiled wxWindows using VC++ 2008 Express. Also am able to compile/link the Calculator example program (haven't tried the others yet).

Now I want to begin writing my own program. So I searched google for tutorials to help get starte. None of them contain main(), and neither does the Calculator example program. I started a new console project and added the Hello World code from one of the tutorials. Since the tutorials don't have main() I deleted main() from my project. It compiles but link gets error

MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
D:\dvlp\simple\Debug\simple.exe : fatal error LNK1120: 1 unresolved externals

So, what am I missing ?

// main.h
class MyApp : public wxApp
{
  public:
    virtual bool OnInit();
};
// simple.h
class Simple : public wxFrame
{
public:
    Simple(const wxString& title);

};
// main.cpp
#include "main.h"
#include "simple.h"

IMPLEMENT_APP(MyApp)

bool MyApp::OnInit()
{
    Simple *simple = new Simple(wxT("Simple"));
    simple->Show(true);

    return true;
}
// simple.cpp
#include "simple.h"

Simple::Simple(const wxString& title)
       : wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(250, 150))
{
  Centre();
}

The project contains these libraries, which I copied from another example project.

wxmsw28d_core.lib wxbase28d.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexd.lib wxexpatd.lib winmm.lib comctl32.lib rpcrt4.lib wsock32.lib odbc32.lib
3
Contributors
4
Replies
6
Views
8 Years
Discussion Span
Last Post by Nick Evan
1

In the Project Properties, Configuration Properties, Linker, System, try setting SubSystem to Windows((/SUBSYSTEM:WINDOWS)

I've been trying to wrap my head around wxWidgets for a couple weeks now (and doing so on both VC++ and XCode on a Mac) and am getting nothing but migraines.

No one seems to put forth a simple, to the point, current tutorial. The only printed book has lots of text, but few, if any, complete samples. And the project startup instructions are not really complete or current.

Votes + Comments
That fixed the problem :)
0

That fixed it. Thanks for the help. So apparently I should have created a windows project, not a console project.

0

That fixed it. Thanks for the help. So apparently I should have created a windows project, not a console project.

Yup.
I've been playing with wxWidgets for a few weeks now, but I have the same experience as vmanes: headaches. :)
Perhaps in the future we can make a tutorial (for DW) on starting wxWidgets with Visual Studio.

0

I take it back.

I was focusing only on the gui part of wx, but apparently wxWidgets also has a lot of console functions.

#include <wx/string.h>

int main()
{
  wxString str1 = wxT("Testing");
  wxString str2 = wxT("console");
  wxString str3 = wxT("functions");

  wxString str = str1 + wxT(" ") + str2 + wxT(" ") + str3;

  wxPuts(str);
}

This should compile on a console-applicatio

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.