Installasjon og test

Mingw64/msys environment:

pacman -Syu
pacman -S 
mingw-w64-x86_64-toolchain 
mingw-w64-x86_64-cmake (for MSYS Makefiles)
git

Åpne CMD

set PATH=msys/usr/bin|mingw64/bin/mappe
git clone --recurse-submodules https://github.com/wxWidgets/wxWidgets.git
cd wxWidgets
mkdir debugBuildStatic
mkdir releaseBuildStatic
cd debugBuildStatic
cmake -G "MSYS Makefiles" ..
cd ../releaseBuildStatic
cmake -G "MSYS Makefiles" ..
cd ..

Gå inn i hver build og endre instillinger med ccmake, configure og generate, make og install

cd debugBuildStatic
ccmake . 
make -jX
make install

ccmakesettings

Lag et nytt prosjekt, main.cpp og resources.rc

cmake_minimum_required(VERSION 3.0)

project(myapp)

set(CMAKE_CXX_STANDARD 20)
set(wxWidgets_DIR "D:/Filer/wxwidgetslib/3.3.0/staticrelease/lib/cmake/wxWidgets")
set(wxWidgets_USE_STATIC ON)

set(SRCS main.cpp)
set(SRCS ${SRCS} resources.rc)

find_package(wxWidgets REQUIRED COMPONENTS core base CONFIG)
include(UsewxWidgets)

add_executable(myapp WIN32 ${SRCS})

target_link_libraries(myapp PRIVATE 
    wx::core 
    wx::base 
    -static
)
#include <wx/wx.h>

class MyApp : public wxApp {
public:
    virtual bool OnInit();
};

class MyFrame : public wxFrame {
public:
    MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);

private:
    void OnHello(wxCommandEvent& event);
    void OnExit(wxCommandEvent& event);
    void OnAbout(wxCommandEvent& event);
    wxDECLARE_EVENT_TABLE();
};

enum {
    ID_Hello = 1
};

wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
    EVT_MENU(ID_Hello,   MyFrame::OnHello)
    EVT_MENU(wxID_EXIT,  MyFrame::OnExit)
    EVT_MENU(wxID_ABOUT, MyFrame::OnAbout)
wxEND_EVENT_TABLE()

IMPLEMENT_APP(MyApp)

bool MyApp::OnInit()
{
    MyFrame *frame = new MyFrame("Hello World", wxPoint(50, 50), wxSize(450, 340));
    frame->Show(true);
    return true;
}

MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
       : wxFrame(NULL, wxID_ANY, title, pos, size)
{
    wxMenu *menuFile = new wxMenu;

    menuFile->Append(ID_Hello, "&Hello...\tCtrl-H",
                     "Help string shown in status bar for this menu item");
    menuFile->AppendSeparator();
    menuFile->Append(wxID_EXIT);

    wxMenu *menuHelp = new wxMenu;
    menuHelp->Append(wxID_ABOUT);

    wxMenuBar *menuBar = new wxMenuBar;
    menuBar->Append(menuFile, "&File");
    menuBar->Append(menuHelp, "&Help");

    SetMenuBar(menuBar);

    CreateStatusBar();
    SetStatusText("Welcome to wxWidgets!");
}

void MyFrame::OnExit(wxCommandEvent& event)
{
    Close(true);
}

void MyFrame::OnAbout(wxCommandEvent& event)
{
    wxMessageBox("This is a wxWidgets' Hello world sample",
                 "About Hello World", wxOK | wxICON_INFORMATION);
}

void MyFrame::OnHello(wxCommandEvent& event)
{
    wxLogMessage("Hello world from wxWidgets!");
}
#include "wx/msw/wx.rc"