Hi there!
We are gearing up to release a version of Tides of Revival, our open world RPG built in Zig. We would like to release a ReleaseSafe version if possible, but have hit a snag (or a few, but this is hopefully the last one)
We have a pretty uncommon setup. First, we are still on Zig 0.14.1 as it seems like it’s not worth the effort upgrading before the release. Second, we rely on a C++ library called The-Forge. We have generated bindings for this library, and are building a dll for it. This dll contains of a few static libraries - some The-Forge libraries (MSVC projects), and one that is our “binding library”.
Third, as implied, we are building with msvc as the target:
"command": "${workspaceFolder}/tools/binaries/zigup/zig build -Dztracy-enable=true -Dtarget=native-native-msvc --summary failures -Doptimize=ReleaseFast -freference-trace",
When we try to build, we get this error:
error: lld-link: /failifmismatch: mismatch detected for ‘RuntimeLibrary’:
note: C:\Projects\elvengroin-legacy.zig-cache\o\efaa0d8879bd7626baf1505d94068554\Log_glue.obj has value MT_StaticRelease
note: OS.lib(CameraController.obj) has value MD_DynamicRelease
Log_glue.cpp is part of the bindings, and here is how we set it up:
pub fn package(
b: *std.Build,
target: std.Build.ResolvedTarget,
optimize: std.builtin.Mode,
_: struct {},
) Package {
const zforge = b.createModule(.{
.target = target,
.optimize = optimize,
.root_source_file = b.path("external/The-Forge/main.zig"),
});
var zforge_cpp = b.addStaticLibrary(.{
.name = "zforge",
.target = target,
.optimize = optimize,
});
zforge_cpp.linkLibC();
// zforge_cpp.linkLibCpp();
zforge_cpp.addIncludePath(b.path("external/The-Forge/Common_3/Application/Interfaces"));
zforge_cpp.addIncludePath(b.path("external/The-Forge/Common_3/Graphics/Interfaces"));
zforge_cpp.addIncludePath(b.path("external/The-Forge/Common_3/Resources/ResourceLoader/Interfaces"));
zforge_cpp.addIncludePath(b.path("external/The-Forge/Common_3/Utilities/Interfaces"));
zforge_cpp.addIncludePath(b.path("Common_3/Utilities/Log"));
zforge_cpp.addCSourceFiles(.{
.files = &.{
"external/The-Forge/Common_3/Application/Interfaces/IFont_glue.cpp",
"external/The-Forge/Common_3/Graphics/Interfaces/IGraphics_glue.cpp",
"external/The-Forge/Common_3/Resources/ResourceLoader/Interfaces/IResourceLoader_glue.cpp",
"external/The-Forge/Common_3/Utilities/Interfaces/IFileSystem_glue.cpp",
"external/The-Forge/Common_3/Utilities/Interfaces/IMemory_glue.cpp",
"external/The-Forge/Common_3/Utilities/Log/Log_glue.cpp",
},
.flags = &.{
"-DTIDES",
"-DNO_TIDES_FORGE_DEBUG",
// "-MD",
},
});
As you can see we’ve tried to add “-MD” to the flags, however that doesn’t have any effect.
You can see the full build.zig for The-Forge here:
And the Tides build.zig here:
Any idea on how we could do this would be helpful.