Develop a Hello World alert for Windows on Arch Linux

Only proceed when all possibilities to avoid Windows have dried up. Proceed with care and suspicion: Clippy takes no prisoners.

Step 1: Hello World

Write the program.


#ifndef UNICODE // Not strictly necessary, but good practice
#define UNICODE

#include <windows.h> // Use Windows libraries

int WINAPI wWinMain(
    HINSTANCE hInstance,     // Handle to current instance
    HINSTANCE hPrevInstance, // Handle to previous instance of application
    PWSTR pCmdLine,          // Command line arguments as Unicode string
    int nCmdShow)            // Open minimised, maximised, or normally
    MessageBox (
        NULL,            // Handle to owner of the message box
        L"Hello world!", // Message to be displayed
        L"Hello",        // Pop-up title
        MB_OKCANCEL);    // Contents and behaviour of pop-up
    return 0;

Further documentation on wWinMain and MessageBox.

Step 2: GNU Compiler Collection

Compile the program.

Running gcc without any modifications will not work, as we require supplementary Windows libraries.

sudo pacman -S mingw-w64-headers mingw-w64-gcc

Then if we run

x86_64-w64-mingw32-g++ helloworld.cpp

we will get an error about an undefined reference to `WinMain' . What we’re missing is the flag -municode.

x86_64-w64-mingw32-g++ -municode helloworld.cpp

Out pops a.exe. We have now created our first Windows program on Arch Linux!

Step 3: Wine

Run the program.

Wine allows us to run Windows programs on Linux. To install Wine on Arch Linux, we will first have to enable the multilib repository by uncommenting two lines in /etc/pacman.conf.


# [multilib]
# Include = /etc/pacman.d/mirrorlist

Then update the repositories, and install the following packages:

sudo pacman -Syu
sudo pacman -S wine wine-mono


wine a.exe

and bask in triumph.


Further steps

Write more programs.

Try following tutorials on creating more involved Windows programs.