WxWidgets

From Schmid.wiki
Jump to: navigation, search

Contents

Topics

Template

#include "wx/wx.h"

class MyApp: public wxApp {
public:
    int OnRun(void);
};
IMPLEMENT_APP(MyApp)

int MyApp::OnRun(void) {
    wxMessageBox(wxT("Hello World!"), wxT("Hello World"));
    return 0;
}

Compile with MSYS/MinGW:

g++ -c `wx-config --cxxflags` minimal.cpp
g++ minimal.o `wx-config --libs` -o minimal.exe

I couldn't get it to work without MSYS.

Windows Installation

Prerequisites: MinGW and MSYS (I couldn't get it to work without msys, and you may have to update your MinGW/MSYS installation)

  • Download and install wxWidgets source archive for Windows
  • start MSYS
  • cd to wxWidgets install dir and ./configure, make, and make install.

Rakefile

Rakefile for MSYS/MingW:

require 'rake/clean'

# OPTIONS --------------------------------------------------------------------
EXES            = FileList['minimal.exe']
COMPILE_OPTIONS = "`wx-config --cxxflags`"
LIBRARY_OPTIONS = "`wx-config --libs`"

# FILE LISTS -----------------------------------------------------------------
SRC = FileList['*.cpp', '*.h']
OBJ = SRC.ext('o')
CLEAN.include OBJ
CLOBBER.include EXES

# TASKS ----------------------------------------------------------------------
desc 'Build application.'
task :default => ['tags'] + EXES

# DEPENDENCIES ---------------------------------------------------------------
file 'minimal.o' => ['minimal.cpp']
file 'minimal.exe' => ['minimal.o']

# COMPILING ------------------------------------------------------------------
rule '.o' => '.cpp' do |t|
    sh "sh -c \"g++ -c #{COMPILE_OPTIONS} -o #{t.name} #{t.source}\""
end

# LINKING --------------------------------------------------------------------
rule '.exe' => '.o' do |t|
    sh "sh -c \"g++ #{t.source} #{LIBRARY_OPTIONS} -o #{t.name}\""
end

References

Personal tools