Having some issues with compiling a basic c++ program using zig (single main.cpp
file that prints “hi” to std::cout
).
I’m getting this error when I run zig build
:
error: root source file struct 'std' has no member named 'Builder'
pub fn build(b: *std.Builder) !void {
~~~^~~~~~~~
/usr/lib/zig/std/std.zig:1:1: note: struct declared here
pub const ArrayHashMap = array_hash_map.ArrayHashMap;
^~~
And my build.zig
file looks like this:
const std = @import("std");
pub fn build(b: *std.Builder) !void {
const mode = b.standardReleaseOptions();
const exe = b.addExecutable("my_cpp_project", "main.cpp");
exe.setBuildMode(mode);
exe.linkLibC(); // Link against the C standard library
exe.addCSourceFile("main.cpp", &[_][]const u8{});
b.installArtifact(exe);
}
Have been searching for a similar problems and cannot find an in-date solution that works. Any ideas what I could be doing wrong here?