I have a zig project that I've built as a static library. I've manually written a C header and want to use it in C projects. But when building my C project with it, I get linker errors:
1>memview.lib(memview.lib.obj) : error LNK2019: unresolved external symbol ___chkstk_ms referenced in function atomic.Atomic.Atomic(u32).init
1>memview.lib(memview.lib.obj) : error LNK2019: unresolved external symbol __divti3 referenced in function io.writer.Writer(*io.fixed_buffer_stream.FixedBufferStream([]u8),error{NoSpaceLeft},(function 'write')).print__anon_8668
1>E:\Dev\third_party\doomgeneric\x64\Debug\doomgeneric.exe : fatal error LNK1120: 2 unresolved externals
It seems like ___chkstk_ms and __divti3 are compiler builtin functions that clang has and zig implements, but MSVC doesn't. I would expect zig to bundle all needed dependencies in the static lib, so this behavior is confusing to me. I have 2 questions:
- Does what I'm doing even make sense? I would think so, since otherwise I'm not sure how any other language could bind to Zig libraries.
- Is this a bug in the zig compiler?
- Any recommendations for manually resolving the linker errors? I'm not sure where to get those functions for the MSVC compiler as part of a static lib.