# \`zig cc -g\` is ignoring me 😭

**URL:** <https://ziggit.dev/t/zig-cc-g-is-ignoring-me/17768>\
**Category:** Help\
**Tags:** c\
**Created:** [October 1, 2026, 2:52pm UTC](https://ziggit.dev/t/zig-cc-g-is-ignoring-me/17768 "2026-10-01T14:52:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![felixrabe](https://ziggit.dev/user_avatar/ziggit.dev/felixrabe/32/5355_2.png) [@felixrabe](https://ziggit.dev/u/felixrabe)\
**Post date:** [October 1, 2026, 2:52pm UTC](https://ziggit.dev/t/zig-cc-g-is-ignoring-me/17768/1 "2026-10-01T14:52:40Z")

</div>

tldr: `-g` works with mingw, but not zig cc. Why?

I’m using Zig 0.16 now, but am open to try master.

* * *

Story time:

I fell into the [Handmade Hero](https://guide.handmadehero.org/) wormhole and started out using (on Arch Linux) `x86_64-w64-mingw32-g++` and `wine` to follow along. So far so good.

```zig
x86_64-w64-mingw32-g++ -mwindows -g -o ./program.exe ./program.cpp
wine ./program.exe

```

I get pretty (~) pictures. Yay. I can even debug using `winedbg --gdb --no-start ./program.exe` and then connect to that with `gf2` for a somewhat bearable debugging experience.

Omitting `-g` results in a (slightly) smaller executable (291K → 275K), so I see it having an effect.

Now I’d like to use Zig for C compilation instead. This works:

```zig
zig cc -target x86_64-windows-gnu -Wl,--subsystem,windows -g -o ./program.exe ./program.cpp -lgdi32
wine ./program.exe

```

The executable is a bit larger (776K) and comes with `program.pdb` (2.7M). Pictures are still pretty (~).

But I see no change whether I specify `-g` or not, or even replace it with `-Doptimize=Debug` (which I don’t think is even interpreted by `zig cc` the same way as `zig build`).

Why? And how do I influence the output of debug information for `zig cc`?

---

<div class="post-metadata">

**Author:** ![ultiman3rd](https://ziggit.dev/user_avatar/ziggit.dev/ultiman3rd/32/8222_2.png) [@ultiman3rd](https://ziggit.dev/u/ultiman3rd)\
**Post date:** [October 1, 2026, 3:00pm UTC](https://ziggit.dev/t/zig-cc-g-is-ignoring-me/17768/2 "2026-10-01T15:00:04Z")

</div>

According to [Andrew Kelley in 2022](https://github.com/ziglang/zig/issues/11194#issuecomment-1071922540), Zig (and zig cc) does not have a -g flag and includes debugging symbols in binaries by default. You can use -s to remove debugging symbols.

---

<div class="post-metadata">

**Author:** ![felixrabe](https://ziggit.dev/user_avatar/ziggit.dev/felixrabe/32/5355_2.png) [@felixrabe](https://ziggit.dev/u/felixrabe)\
**Post date:** [October 1, 2026, 3:10pm UTC](https://ziggit.dev/t/zig-cc-g-is-ignoring-me/17768/3 "2026-10-01T15:10:51Z")

</div>

Ah, good to know, thanks!
