Skip to content

Instantly share code, notes, and snippets.

@lboulard
Last active October 16, 2022 09:01
Show Gist options
  • Save lboulard/0a1ec400a42dc55f8bf78e09d5252df2 to your computer and use it in GitHub Desktop.
Save lboulard/0a1ec400a42dc55f8bf78e09d5252df2 to your computer and use it in GitHub Desktop.
Build Ragel 6.10 on windows with MSYS2/MINGW64

Build Windows 64-bit ragel executable

Use MSYS2 and UCRT64 environment. Existing ragel is required. We use existing package from UCRT64 that depends on libgcc, libstdc++ and libwinpthread.

pacman -S --needed autotools git mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-ragel

Fetch http://www.colm.net/files/kelbt/kelbt-0.16.tar.gz as prerequisite. Also included in gist on GitHub.

tar xf kelbt-0.16.tar.gz
cd kelbt-0.16
./configure
make -j
make install-exec

Fetch version 6.10 of ragel. THIS MUST DONE IN MINGW64 environment.

git -c core.eol=lf -c core.autocrlf=false clone -b ragel-6.10 https://github.com/adrian-thurston/ragel.git

Fix a bug for code generation with D language with this patch.

patch -l -p1 <<"EOF"
diff --git a/ragel/cdcodegen.cpp b/ragel/cdcodegen.cpp
--- a/ragel/cdcodegen.cpp
+++ b/ragel/cdcodegen.cpp
@@ -782,12 +782,12 @@ string DCodeGen::POINTER()

 string DCodeGen::PTR_CONST()
 {
-       return "";
+       return "const(";
 }

 string DCodeGen::PTR_CONST_END()
 {
-       return "";
+       return ")";
 }
EOF

Autoconf sources are quite old, run autoupdate before autogen.sh. We only build the binary. Examples build would fail on absence of demonstration language installed.

autoupdate
./autogen.sh
LDFLAGS="--static" ./configure --disable-manual
make -j

Verify this is a static binary

ldd ./ragel/ragel.exe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment