# "Duplicate symbol definition" error when using incremental compilation with zig sqlite library

**URL:** <https://ziggit.dev/t/duplicate-symbol-definition-error-when-using-incremental-compilation-with-zig-sqlite-library/12717>\
**Category:** Help\
**Tags:** c, zig-0-15-1, zig-0-15-2\
**Created:** [October 28, 2025, 5:21am UTC](https://ziggit.dev/t/duplicate-symbol-definition-error-when-using-incremental-compilation-with-zig-sqlite-library/12717 "2025-10-28T05:21:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![glitchcake](https://ziggit.dev/user_avatar/ziggit.dev/glitchcake/32/2361_2.png) [@glitchcake](https://ziggit.dev/u/glitchcake)\
**Post date:** [October 28, 2025, 5:21am UTC](https://ziggit.dev/t/duplicate-symbol-definition-error-when-using-incremental-compilation-with-zig-sqlite-library/12717/1 "2025-10-28T05:21:32Z")

</div>

I am running `zig build test -fincremental --watch` in a [minimal repo](https://codeberg.org/glitchcake/repro) having had been created with `zig init` and having had [this zig-sqlite package](https://github.com/nDimensional/zig-sqlite) added.

When I make changes to a file, I get compile errors like this until I kill and restart the zig build test process:

```plaintext
Build Summary: 2/5 steps succeeded; 1 failed; 1/1 tests passed
test transitive failure
└─ run test transitive failure
   └─ compile test Debug native 273 errors

test
└─ run test
   └─ compile test Debug native 273 errors
error: duplicate symbol definition: sqlite3_status64
    note: defined by .zig-cache/o/0d9f330882b0082415928ee467f2861d/sqlite3.o
    note: defined by .zig-cache/o/0d9f330882b0082415928ee467f2861d/sqlite3.o
error: duplicate symbol definition: sqlite3_mutex_enter
    note: defined by .zig-cache/o/0d9f330882b0082415928ee467f2861d/sqlite3.o
    note: defined by .zig-cache/o/0d9f330882b0082415928ee467f2861d/sqlite3.o
[it goes on like this for a bit, and then ends with]
error: 273 compilation errors

Build Summary: 2/5 steps succeeded; 1 failed; 1/1 tests passed
test transitive failure
└─ run test transitive failure
   └─ compile test Debug native 273 errors

```

That is, it works the first time I start the process, but once I make any change and save to trigger the watcher to run again, these duplicate symbol errors show up. Does anyone know why this would be happening, or how to fix it if possible?

Same behavior observed with zig 0.15.1 and 0.15.2

Cheers and thank you!

---

<div class="post-metadata">

**Author:** ![ScottRedig](https://ziggit.dev/user_avatar/ziggit.dev/scottredig/32/5880_2.png) [@ScottRedig](https://ziggit.dev/u/ScottRedig)\
**Post date:** [October 28, 2025, 7:39am UTC](https://ziggit.dev/t/duplicate-symbol-definition-error-when-using-incremental-compilation-with-zig-sqlite-library/12717/2 "2025-10-28T07:39:06Z")

</div>

Incremental should not have any different behavior, so assuming your code works when not using incremental, that’s a bug.

Searching on github, look to see if any of these issues are relevant: [GitHub · Where software is built](https://github.com/ziglang/zig/issues?q=is%3Aissue%20%22duplicate%20symbol%20definition%22)

If they aren’t, then file a new issue on github.

---

<div class="post-metadata">

**Author:** ![glitchcake](https://ziggit.dev/user_avatar/ziggit.dev/glitchcake/32/2361_2.png) [@glitchcake](https://ziggit.dev/u/glitchcake)\
**Post date:** [October 28, 2025, 12:48pm UTC](https://ziggit.dev/t/duplicate-symbol-definition-error-when-using-incremental-compilation-with-zig-sqlite-library/12717/3 "2025-10-28T12:48:36Z")

</div>

I don’t use Github, but thanks anyways

---

<div class="post-metadata">

**Author:** ![glitchcake](https://ziggit.dev/user_avatar/ziggit.dev/glitchcake/32/2361_2.png) [@glitchcake](https://ziggit.dev/u/glitchcake)\
**Post date:** [October 28, 2025, 1:15pm UTC](https://ziggit.dev/t/duplicate-symbol-definition-error-when-using-incremental-compilation-with-zig-sqlite-library/12717/4 "2025-10-28T13:15:12Z")

</div>

I spaced over the first part; doing a search is a great call, thanks. I did find this:

> <https://github.com/ziglang/zig/issues/25148>
>
> \### Zig Version
> 
> 0.16.0-dev.168+d51d18c98
> 
> \### Steps to Reproduce and Observed B…ehavior
> 
> 1. Create a project which combines C and Zig sources using \`addCSourceFile\`.
> 
> For example (\[download full MRE\](https://github.com/user-attachments/files/22141522/repro.tar.gz)):
> #### \*\*answer.c\*\*
> \`\`\`c
> unsigned char answer(void) {
> return 42;
> }
> \`\`\`
> #### \*\*main.zig\*\*
> \`\`\`zig
> extern fn answer() u8;
> 
> pub fn main() u8 {
> return answer();
> }
> \`\`\`
> 1. In one terminal: \`zig build --watch -fincremental\`. Build succeeds; leave this running.
> \`\`\`
> Build Summary: 3/3 steps succeeded
> install success
> └─ install zig\_bugtest success
> └─ compile exe zig\_bugtest Debug native success 433ms
> \`\`\`
> 1. In another terminal, \`touch main.zig\`. Incremental rebuild fails:
> \`\`\`
> install
> └─ install zig\_bugtest
> └─ compile exe zig\_bugtest Debug native 1 errors
> error: duplicate symbol definition: answer
> note: defined by main.o
> note: defined by .zig-cache/o/947b2dda26b0849e5693c298de54308f/answer.o
> error: 1 compilation errors
> 
> Build Summary: 0/3 steps succeeded; 1 failed
> install transitive failure
> └─ install zig\_bugtest transitive failure
> └─ compile exe zig\_bugtest Debug native 1 errors
> \`\`\`
> The same thing happens if you \`touch answer.c\`.
> 
> \### Expected Behavior
> 
> Successful rebuild (or better, no rebuild, since the file contents did not change).
