• Stars
    star
    2,871
  • Rank 15,800 (Top 0.4 %)
  • Language
    C
  • License
    The Unlicense
  • Created over 4 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Portable C and C++ Development Kit for x64 (and x86) Windows

Portable C and C++ Development Kit for x64 Windows

w64devkit is a Dockerfile that builds from source a small, portable development suite for creating C and C++ applications on and for x64 Windows. See "Releases" for pre-built, ready-to-use kits.

Included tools:

The toolchain includes pthreads, C++11 threads, and OpenMP. All included runtime components are static. Docker/Podman is not required to use the development kit. It's merely a reliable, clean environment for building the kit itself.

Build

First build the image, then run it to produce a distribution .zip file:

docker build -t w64devkit .
docker run --rm w64devkit >w64devkit.zip

This takes about half an hour on modern systems. You will need an internet connection during the first few minutes of the build. Note: Do not use PowerShell because it lacks file redirection.

Usage

The final .zip file contains tools in a typical unix-like configuration. Unzip the contents anywhere. Inside is w64devkit.exe, which launches a console window with the environment configured and ready to go. It is the easiest way to enter the development environment, and requires no system changes. It also sets two extra environment variables: W64DEVKIT_HOME to the installation root and W64DEVKIT to the version.

Alternatively, add the bin/ directory to your path. For example, inside a cmd.exe console or batch script:

set PATH=c:\path\to\w64devkit\bin;%PATH%

Then to start an interactive unix shell:

sh -l

Main features

  • No installation required. Run it anywhere as any user. Simply delete when no longer needed.

  • Fully offline. No internet access is ever required or attempted.

  • A focus on static linking all runtime components. The runtime is optimized for size.

  • Trivial to build from source, meaning it's easy to tweak and adjust any part of the kit for your own requirements.

  • Complements Go for cgo and bootstrapping.

Optimized for size

The language runtimes in w64devkit are optimized for size, so it produces particularly small binaries when programs are also optimized for size (-Os) during compilation. If your program only uses the printf family of functions with MSVC-compatible directives (i.e. limited to C89), and you want even smaller binaries, you can avoid embedding the Mingw-w64's improved implementation by setting __USE_MINGW_ANSI_STDIO to 0 before including any headers.

$ cc -Os -D__USE_MINGW_ANSI_STDIO=0 ...

Fortran support

Only C and C++ are included by default, but w64devkit also has full support for Fortran. To build a Fortran compiler, add fortran to the --enable-languages lines in the Dockerfile.

Recommended downloadable, offline documentation

With a few exceptions, such as Vim's built-in documentation (:help), w64devkit does not include documentation. However, you need not forgo offline documentation alongside your offline development tools. This is a list of recommended, no-cost, downloadable documentation complementing w64devkit's capabilities. In rough order of importance:

  • cppreference (HTML), friendly documentation for the C and C++ standard libraries.

  • GCC manuals (PDF, HTML), to reference GCC features, especially built-ins, intrinsics, and command line switches.

  • Win32 Help File (CHM) is old, but official, Windows API documentation. Unfortunately much is missing, such as Winsock. (Offline Windows documentation has always been very hard to come by.)

  • C and C++ Standards (drafts) (PDF), for figuring out how corner cases are intended to work.

  • Intel Intrinsics Guide (interactive HTML), a great resource when working with SIMD intrinsics. (Search for "Download" on the left.)

  • GNU Make manual (PDF, HTML)

  • GNU Binutils manuals (PDF, HTML), particularly ld and as.

  • GDB manual (PDF)

  • BusyBox man pages (TXT), though everything here is also available via -h option inside w64devkit.

  • NASM manual (PDF)

  • Intel Software Developer Manuals (PDF), for referencing x86 instructions, when either studying compiler output with objdump, or writing assembly with nasm or as.

Library installation

Except for the standard libraries and Win32 import libraries, w64devkit does not include libraries, but you can install additional libraries such that the toolchain can find them naturally. There are three options:

  1. Install it under the sysroot at w64devkit/$ARCH/. The easiest option, but will require re-installation after upgrading w64devkit. If it defines .pc files, the pkg-config command will automatically find and use them.

  2. Append its installation directory to your CPATH and LIBRARY_PATH environment variables. Use ; to delimit directories. You would likely do this in your .profile.

  3. If it exists, append its pkgconfig directory to the PKG_CONFIG_PATH environment variable, then use the pkg-config command as usual. Use ; to delimit directories

Both (1) and (3) are designed to work correctly even if w64devkit or the libraries have paths containing spaces.

Cppcheck tips

Use --library=windows for programs calling the Win32 API directly, which adds additional checks. In general, the following configuration is a good default for programs developed using w64devkit:

$ cppcheck --quiet -j$(nproc) --library=windows \
           --suppress=uninitvar --enable=portability,performance .

A "strict" check that is more thorough, but more false positives:

$ cppcheck --quiet -j$(nproc) --library=windows \
      --enable=portability,performance,style \
      --suppress=uninitvar --suppress=unusedStructMember \
      --suppress=constVariable --suppress=shadowVariable \
      --suppress=variableScope --suppress=constParameter \
      --suppress=shadowArgument --suppress=knownConditionTrueFalse .

Notes

$HOME can be set through the adjacent w64devkit.ini configuration, and may even be relative to the w64devkit/ directory. This is useful for encapsulating the entire development environment, with home directory, on removable, even read-only, media. Use a .profile in the home directory to configure the environment further.

I'd love to include Git, but unfortunately Git's build system doesn't quite support cross-compilation. A decent alternative would be Quilt, but it's written in Bash and Perl.

Neither Address Sanitizer (ASan) nor Thread Sanitizer (TSan) has been ported to Mingw-w64 (also), but Undefined Behavior Sanitizer (UBSan) works perfectly under GDB. With both -fsanitize=undefined and -fsanitize-trap, GDB will break precisely on undefined behavior, and it does not require linking with libsanitizer.

The kit includes a unique debugbreak command. It causes all debugee processes to break in the debugger, like using Windows' F12 debugger hotkey. This is especially useful for console subsystem programs.

Since the build environment is so stable and predicable, it would be great for the .zip to be reproducible, i.e. builds by different people are bit-for-bit identical. There are multiple reasons why this is not currently the case, the least of which are timestamps in the .zip file.

Licenses

When distributing binaries built using w64devkit, your .exe will include parts of this distribution. For the GCC runtime, including OpenMP, you're covered by the GCC Runtime Library Exception so you do not need to do anything. However the Mingw-w64 runtime has the usual software license headaches and you may need to comply with various BSD-style licenses depending on the functionality used by your program: MinGW-w64 runtime licensing and winpthreads license. To make this easy, w64devkit includes the concatenated set of all licenses in the file COPYING.MinGW-w64-runtime.txt, which should be distributed with your binaries.

More Repositories

1

endlessh

SSH tarpit that slowly sends an endless banner
C
7,113
star
2

elfeed

An Emacs web feeds client
Emacs Lisp
1,371
star
3

skewer-mode

Live web development in Emacs
Emacs Lisp
1,066
star
4

hash-prospector

Automated integer hash function discovery
C
672
star
5

enchive

Encrypted personal archives
C
630
star
6

branchless-utf8

Branchless UTF-8 decoder
C
589
star
7

scratch

Personal scratch code
C
366
star
8

pixelcity

Shamus Young's procedural city project
C++
359
star
9

optparse

Portable, reentrant, getopt-like option parser
C
326
star
10

pdjson

C JSON parser library that doesn't suck
C
279
star
11

interactive-c-demo

Demonstration of interactive C programming
C
249
star
12

emacs-aio

async/await for Emacs Lisp
Emacs Lisp
215
star
13

webgl-particles

WebGL particle system demo
JavaScript
203
star
14

fantasyname

Fantasy name generator
C
180
star
15

lstack

C11 Lock-free Stack
C
172
star
16

resurrect-js

JavaScript serialization that preserves behavior and reference circularity.
JavaScript
169
star
17

passphrase2pgp

Generate a PGP key from a passphrase
Go
168
star
18

pure-linux-threads-demo

Pthreads-free Linux threading demo
Assembly
147
star
19

ptrace-examples

Examples for Linux ptrace(2)
C
134
star
20

memdig

Memory cheat tool for Windows and Linux games
C
131
star
21

dosdefender-ld31

DOS Defender (Ludum Dare #31)
C
130
star
22

dotfiles

My personal dotfiles
Shell
124
star
23

Prelude-of-the-Chambered

Notch's Prelude of the Chambered 48-hour game
Java
124
star
24

sort-circle

Colorful sorting animations
C
124
star
25

.emacs.d

My personal .emacs.d
Emacs Lisp
119
star
26

growable-buf

Growable Memory Buffer for C99
C
116
star
27

youtube-dl-emacs

Emacs youtube-dl download manager
Emacs Lisp
104
star
28

getopt

POSIX getopt() as a portable header library
C
102
star
29

trie

C99 trie library
C
98
star
30

opengl-demo

Minimal OpenGL 3.3 core profile demo
C
97
star
31

Minicraft

Notch's Ludum Dare 22 entry.
Java
95
star
32

igloojs

Low-level, fluent, OOP WebGL wrapper
JavaScript
89
star
33

hastyhex

A blazing fast hex dumper
C
88
star
34

webgl-game-of-life

WebGL Game of Life
JavaScript
88
star
35

u-config

a smaller, simpler, portable pkg-config clone
C
84
star
36

bmp

24-bit BMP (Bitmap) ANSI C header library
C
84
star
37

elisp-ffi

Emacs Lisp Foreign Function Interface
C++
83
star
38

rng-js

JavaScript seedable random number generation tools.
JavaScript
82
star
39

mandel-simd

Mandelbrot set in SIMD (SSE, AVX)
C
81
star
40

sample-java-project

Example Ant-based Java project
Java
78
star
41

nasm-mode

Major mode for editing NASM assembly programs
Emacs Lisp
78
star
42

vulkan-test

Test if your system supports Vulkan
C
77
star
43

gap-buffer-animator

Gap buffer animation creator
C
72
star
44

at-el

Prototype-based Emacs Lisp object system
Emacs Lisp
71
star
45

skeeto.github.com

Personal website/blog
HTML
64
star
46

ulid-c

ULID Library for C
C
62
star
47

xf8

8-bit Xor Filter in C99
C
61
star
48

race64

World's fastest Base64 encoder / decoder
C
58
star
49

devdocs-lookup

Quick Emacs API lookup on devdocs.io
Emacs Lisp
58
star
50

webgl-path-solver

WebGL shortest path solver
JavaScript
57
star
51

x86-lookup

Quickly jump to x86 documentation from Emacs
Emacs Lisp
57
star
52

javadoc-lookup

Quickly lookup Javadoc pages from Emacs
Emacs Lisp
55
star
53

am-i-shadowbanned

Online reddit shadowban test
JavaScript
53
star
54

fun-liquid

Physics engine liquid in Java.
Java
53
star
55

minimail

Embeddable POP3 + SMTP server.
C
50
star
56

emacs-memoize

Elisp memoization functions
Emacs Lisp
48
star
57

webgl-fire

WebGL fire effect
JavaScript
47
star
58

simplegpg

Simplified, signify-like interface to GnuPG signatures
Shell
47
star
59

autotetris-mode

Automatically play Emacs Tetris
Emacs Lisp
45
star
60

fiber-await

Win32 Fiber async/await demo
C
45
star
61

lorenz-webgl

Lorenz System WebGL
JavaScript
42
star
62

asteroids-demo

Asteroids Clone for Windows
C
40
star
63

elisp-json-rpc

JSON-RPC library for Emacs Lisp
Emacs Lisp
39
star
64

hashtab

Simple C hash table
C
37
star
65

pgp-poisoner

PGP key poisoner
Go
36
star
66

bf-x86

x86_64 brainfuck compiler
C
36
star
67

wisp

Wisp, a lisp programming language
C
33
star
68

binitools

Bini file translator for the game Freelancer
C
32
star
69

double-pendulum

JavaScript double pendulum simulation with RK4 integration
JavaScript
30
star
70

predd

Multimethods for Emacs Lisp
Emacs Lisp
29
star
71

atomkv

In-memory, JSON, key-value service with compare-and-swap updates and event streams
Go
29
star
72

purgeable

Purgeable memory allocations for Linux
C
28
star
73

lqueue

C11 + Pthreads Atomic Bounded Work Queue
C
28
star
74

uuid

UUID generator for Go
Go
27
star
75

goblin-com

Goblin-COM roguelike game for 7DRL 2015
C
27
star
76

jekyll-deck

Template for Jekyll / deck.js presentations
27
star
77

rlhk

Roguelike Header Kit
C
26
star
78

voronoi-toy

WebGL interactive Voronoi diagram
JavaScript
26
star
79

transcription-mode

Emacs mode for editing transcripts.
Emacs Lisp
25
star
80

october-chess-engine

Java Chess Engine
Java
25
star
81

boids-js

HTML5 boids (skewer-mode demo)
JavaScript
25
star
82

optparse-go

GNU style long options for Go
Go
24
star
83

geohash

Fast, lean, efficient geohash C library
C
24
star
84

bitpack

Emacs Lisp structure packing
Emacs Lisp
23
star
85

lean-static-gpg

Lean, static GnuPG build for Linux
Shell
23
star
86

connect4

Connect Four AI and Engine
C
22
star
87

blowpipe

Authenticated Blowfish-encrypted pipe
C
22
star
88

markov-text

Markov chain text generation in Emacs Lisp
Emacs Lisp
22
star
89

joymacs

Joystick support for Emacs
C
21
star
90

emacs-rsa

RSA cryptography in Emacs Lisp
Emacs Lisp
21
star
91

live-dev-env

A live CD of my personal development environment
Shell
20
star
92

dynamic-function-benchmark

Benchmark for three different kinds of dynamic function calls
C
20
star
93

utf-7

UTF-7 encoder and decoder in ANSI C
C
19
star
94

elisp-fakespace

Emacs Lisp namespaces (defpackage)
Emacs Lisp
18
star
95

siphash

Incremental SipHash in C
C
18
star
96

bencode-c

Bencode decoder in ANSI C
C
17
star
97

british-square

British Square Engine (Analysis and Perfect AI Player)
C
17
star
98

pokerware

Pokerware Secure Passphrase Generation
Makefile
17
star
99

xxtea

100% XXTEA authenticated, chunked file encryption
C
17
star
100

gnupg-windows-build

Cross-compile GnuPG for Windows using Docker
Dockerfile
17
star