I am new to the Zig language and have a question about creating a 32-bit Windows DLL.
I am using zig-windows-x86_64-0.11.0-dev.2612+56d800ff7.zip
.
I have created a project using zig init-lib
, but the generated build.zig
seemed to be for a static library, so I ignored it.
To create a release build without debug information, I used the following command:
zig build-lib -O ReleaseFast -fstrip -target x86-windows-gnu -dynamic src/main.zig
However, this command produced several undefined symbol
errors, such as:
error: lld-link: <root>: undefined symbol: _DllMainCRTStartup@12
error: lld-link: <root>: undefined symbol: add
error: lld-link: <root>: undefined symbol: _tls_index
error: lld-link: <root>: undefined symbol: _tls_start
error: lld-link: <root>: undefined symbol: _tls_end
error: lld-link: <root>: undefined symbol: __xl_a
error: lld-link: <root>: undefined symbol: __xl_z
error: lld-link: <root>: undefined symbol: _tls_used
Adding -lc
to the options allowed the compilation to succeed, but I don't think this is the correct solution since Zig doesn't depend on the C runtime.
I want to know if there's a way to compile without the C runtime.
Additionally, inspecting the generated main.dll
with dumpbin /EXPORTS
shows that _DllMainCRTStartup@12
is exported:
ordinal hint RVA name
1 0 00001000 _DllMainCRTStartup@12 = __DllMainCRTStartup@12
2 1 00001010 add = _add
I believe it is unnecessary as it's the DLL entry point and shouldn't be used by GetProcAddress
.
Please tell me if there is a reason why this is being exported, or if there is a way to prevent it from being exported.
I discovered that commenting out the @export
in lib/std/start.zig
achieved the desired behavior, but obviously this is not a smart.
I'm looking for the most appropriate solution.