#Passing options to clang

1 messages · Page 1 of 1 (latest)

opaque quarry
#

Hi, I was using c++ with msvc for a project but am looking into moving things over to zig. It was going well but have hit a snag.

The project links against a closed source library and when compiling with msvc I found I had to set the -MD option (https://learn.microsoft.com/en-us/cpp/build/reference/md-mt-ld-use-run-time-library?view=msvc-170) otherwise the program would crash at runtime if compiled in debug mode (but worked fine in release). I guess this is some incompatibility between the library and the debug windows runtime.

How can I pass this same option to clang when compiling with zig? Clang should support it I believe as listed here https://clang.llvm.org/docs/UsersManual.html#clang-cl

I tried this with the flags argument to addCSourceFile but no luck:

exe.addCSourceFile(.{
.file = .{ .path = "src/rmanBindings.cpp" },
.flags = &.{"-MD"},
});

Currently with zig I get the same behavior as I used to with msvc without -MD, in that the program crashes if compiled with Debug but is fine when compiled with ReleaseSafe.

Many thanks.

Learn more about: /MD, /MT, /LD (Use Run-Time Library)

pulsar pasture
#

-MD has a different meaning to cl.exe style arg /MD
it means create a dependency file (in a unix make-compatible format)