I am learning wxWidgets to break free of console programming. I use Dev-C++, and I have installed all necessary DevPaks, and everything should work fine, except when I try and compile this code, I get:
[Linker error] undefined reference to `WinMain@16'
ld returned 1 exit status
C:\Dev-Cpp\Makefile.win [Build Error] [Testing.exe] Error 1

#include <wx/wxprec.h>
#include <wx/wx.h>

// Declare the application class
class MyApp : public wxApp
{
public:
// Called on application startup
virtual bool OnInit();
};

bool MyApp::OnInit()
{
// Create the main application window
wxFrame *frame = new wxFrame;
// Show it
frame->Show(true);
// Start the event loop
return true;
}

Please help me fix what's wrong, thank you. :)

Nevermind! I solved it. I didn't add these:

DECLARE_APP(MyApp)
IMPLEMENT_APP(MyApp)

and don't use Dev-C++, use Updated IDE like wxDevCpp, CodeLite or Code::Blocks

And this is bad coding.
Make separate .h and .cpp files for your top level windows class which inherits wxFrame and do your stuffs there. Then Instantiate that class in main app.

wxFrame *frame = new wxFrame;

Grab yourself this book and start reading

and don't use Dev-C++, use Updated IDE like wxDevCpp, CodeLite or Code::Blocks

And this is bad coding.
Make separate .h and .cpp files for your top level windows class which inherits wxFrame and do your stuffs there. Then Instantiate that class in main app.

wxFrame *frame = new wxFrame;

Grab yourself this book and start reading

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.