So trying to build this Detours project.
So far their “Makefile” seems to support MinGW my attempts:
fn configDetours(lib: *std.Build.Step.Compile, target: std.Target) !void {
const exclude_files = [_][]const u8{
"uimports.cpp",
};
const b = lib.step.owner;
const detoursDir = b.path("Detours/src");
const path = detoursDir.getPath3(b, &lib.step);
var dir = try path.openDir("", .{ .iterate = true });
var dir_iter = dir.iterate();
defer dir.close();
outer_loop: while (try dir_iter.next()) |entry| {
if (entry.kind != .file) continue;
if (!std.ascii.endsWithIgnoreCase(entry.name, ".cpp")) continue;
for (exclude_files) |exclude_file| {
if (std.ascii.eqlIgnoreCase(entry.name, exclude_file)) continue :outer_loop;
}
const source_file_path = try detoursDir.join(b.allocator, entry.name);
lib.addCSourceFile(.{ .file = source_file_path, .language = null, .flags = &.{"-DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x501"} });
}
lib.linkLibC();
if (target.abi != .msvc) {
lib.linkLibCpp();
}
}
const detours = b.addStaticLibrary(.{
.name = "detours",
.target = target,
.optimize = optimize,
});
try configDetours(detours, target.result);
// link with others or other stuff
But as from the title I get that undefined symbol error, I am actually not familiar with MinGW that much but I think they got that _CrtDbgReport
implemented?
I see zig/lib/libc/include/any-windows-any/crtdbg.h at d238078ae87f1beb565d42caee01ebd6a7a00d43 · ziglang/zig · GitHub has defined? but don’t know much about it either, zig build -Dtarget=x86_64-windows-msvc
is fine with the above approach.