agentleFS
abduznikabduznik/abduznik-skills/skills/windows-c-build-toolchain/SKILL.md

windows-c-build-toolchain

Skill2 starsChanged 2 months agoMITView on GitHub

Build C/C++ on Windows with MSYS2 MinGW GCC.

  • Deletes or force-pushes

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Exit code 1 with no output: If gcc exits 1 with no error messages, it is likely being killed by antivirus.

    line 76

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Windows C Build Toolchain (MSYS2 MinGW GCC)

When to Use

Building C/C++ projects on Windows when Visual Studio Build Tools are not installed or unavailable.

Setup

# Install MSYS2 via winget
winget install MSYS2.MSYS2

# Fix PGP keyring (run once from MSYS2 bash)
C:/msys64/usr/bin/bash.exe -lc "
rm -rf /etc/pacman.d/gnupg
pacman-key --init
pacman-key --populate msys2
"

# Install GCC
C:/msys64/usr/bin/bash.exe -lc "pacman -S --noconfirm mingw-w64-x86_64-gcc"

Build

Always invoke gcc through MSYS2 bash, not directly from Git Bash. Windows Defender silently kills cc1.exe when invoked from Git Bash (the terminal tool). The MSYS2 shell does not have this issue.

# WRONG — fails silently (exit 1, no output):
C:/msys64/mingw64/bin/gcc.exe -c file.c

# CORRECT — works:
C:/msys64/usr/bin/bash.exe -lc "
export PATH=/mingw64/bin:\$PATH
cd /c/Users/admin/projects/myproject
gcc -shared -o library.dll source.c -lkernel32 -ladvapi32
"

Common Fixes

Implicit declaration of function

GCC requires forward declarations. If a function is used in one .c file but defined in another, add extern declaration in a shared header:

// In shared_header.h
extern double my_function(HANDLE handle);

Linking Windows APIs

gcc -shared -o library.dll source.c \
  -lkernel32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lwbemuuid

Pitfalls

  • Windows Defender kills cc1.exe from Git Bash: The MSYS2 gcc toolchain works fine from MSYS2 bash but fails silently from Git Bash. Always wrap gcc calls in C:/msys64/usr/bin/bash.exe -lc "...".
  • MSYS2 PGP keyring corruption: Fresh MSYS2 install may have invalid package signatures. Fix by removing and reinitializing the keyring.
  • Exit code 1 with no output: If gcc exits 1 with no error messages, it is likely being killed by antivirus. Check Windows Defender protection history.
  • Missing forward declarations: GCC is stricter than MSVC about implicit function declarations. Every function used in a translation unit must be declared before use.

Reference

See references/w64devkit-lightweight-mingw.md for the alternative lightweight MinGW distribution (~60MB, no installer).

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.