I have written a minimal wxWidgets application:
stdafx.h
#define wxNO_REGEX_LIB
#define wxNO_XML_LIB
#define wxNO_NET_LIB
#define wxNO_EXPAT_LIB
#define wxNO_JPEG_LIB
#define wxNO_PNG_LIB
#define wxNO_TIFF_LIB
#define wxNO_ZLIB_LIB
#define wxNO_ADV_LIB
#define wxNO_HTML_LIB
#define wxNO_GL_LIB
#define wxNO_QA_LIB
#define wxNO_XRC_LIB
#define wxNO_AUI_LIB
#define wxNO_PROPGRID_LIB
#define wxNO_RIBBON_LIB
#define wxNO_RICHTEXT_LIB
#define wxNO_MEDIA_LIB
#define wxNO_STC_LIB
#include <wx/wxprec.h>
Minimal.cpp
#include "stdafx.h"
#include <memory>
#include <wx/wx.h>
class Minimal : public wxApp
{
public:
virtual bool OnInit();
};
IMPLEMENT_APP(Minimal)
DECLARE_APP(Minimal)
class MinimalFrame : public wxFrame
{
DECLARE_EVENT_TABLE()
public:
MinimalFrame(const wxString& title);
void OnQuit(wxCommandEvent& e);
void OnAbout(wxCommandEvent& e);
};
BEGIN_EVENT_TABLE(MinimalFrame, wxFrame)
EVT_MENU(wxID_ABOUT, MinimalFrame::OnAbout)
EVT_MENU(wxID_EXIT, MinimalFrame::OnQuit)
END_EVENT_TABLE()
MinimalFrame::MinimalFrame(const wxString& title)
: wxFrame(0, wxID_ANY, title)
{
std::auto_ptr<wxMenu> fileMenu(new wxMenu);
fileMenu->Append(wxID_EXIT, L"E&xit\tAlt-X",
L"Terminate the Minimal Example.");
std::auto_ptr<wxMenu> helpMenu(new wxMenu);
helpMenu->Append(wxID_ABOUT, L"&About\tF1",
L"Show the about dialog box.");
std::auto_ptr<wxMenuBar> bar(new wxMenuBar);
bar->Append(fileMenu.get(), L"&File");
fileMenu.release();
bar->Append(helpMenu.get(), L"&Help");
helpMenu.release();
SetMenuBar(bar.get());
bar.release();
CreateStatusBar(2);
SetStatusText(L"Welcome to wxWidgets!");
}
void MinimalFrame::OnAbout(wxCommandEvent& e)
{
wxMessageBox(L"Some text about me!", L"About", wxOK, this);
}
void MinimalFrame::OnQuit(wxCommandEvent& e)
{
Close();
}
bool Minimal::OnInit()
{
std::auto_ptr<MinimalFrame> mainFrame(
new MinimalFrame(L"Minimal wxWidgets Application"));
mainFrame->Show();
mainFrame.release();
return true;
}
This minimal program weighs in at 2.4MB! (Executable compression drops this to half a MB or so but that's still HUGE!) (I must statically link because this application needs to be single-binary-xcopy-deployed, so both the C runtime and wxWidgets itself are set for static linking)
Any tips on cutting this down? (I'm using Microsoft Visual Studio 2010)