andrewrk / sdl-zig-demo

SDL2 hello world in zig
MIT License
129 stars 23 forks source link

error: no member named 'addCommand' in struct 'std.build.Builder' #2

Open xyproto opened 6 years ago

xyproto commented 6 years ago

When checking out this repository and building with zig build I get the following:

% zig build
/home/alexander/clones/sdl-zig-demo/src/main.zig:1:11: error: C import failed
const c = @cImport({
          ^
/usr/lib/zig/include/immintrin.h:351:10: note: 'wbnoinvdintrin.h' file not found
#include <wbnoinvdintrin.h>
         ^
The following command exited with error code 1:
zig build-exe /home/alexander/clones/sdl-zig-demo/src/main.zig --cache-dir /home/alexander/clones/sdl-zig-demo/zig-cache --output /home/alexander/clones/sdl-zig-demo/zig-cache/sdl-zig-demo --name sdl-zig-demo --library c --library SDL2 

Build failed. The following command failed:
/home/alexander/.local/share/zig/stage1/artifact/rWbvqhsrW8aj7QYIdeohdhUn5pl7yGy0J2mLlT8ZusC-H8lblEOBwIl1bO69XJ3F/build zig /home/alexander/clones/sdl-zig-demo /home/alexander/clones/sdl-zig-demo/zig-cache

sdl2 version 2.0.9 is installed.

I have no idea what wbnoinvdintrin.h is, I've never seen it before.

xyproto commented 6 years ago

My plan is to add a zig example to this collection of SDL2 examples, if I can get it to work.

xyproto commented 5 years ago

When building with zig 0.4.0+e553ade0 I get:

/sdl-zig-demo/build.zig:15:22: error: no member named 'addCommand' in struct 'std.build.Builder'
    const run_cmd = b.addCommand(".", b.env_map,
                     ^
xyproto commented 5 years ago

I tried this again with the latest version of zig (0.4.0+50c8a93a) and the latest commit from this repository. This is the result:

% zig build
/home/afr/clones/sdl-zig-demo/build.zig:15:22: error: no member named 'addCommand' in struct 'std.build.Builder'
const run_cmd = b.addCommand(".", b.env_map,
^
/home/afr/clones/sdl-zig-demo/build.zig:16:21: error: expected array type or [_], found slice
[][]const u8{exe.getOutputPath(), });
^
Costava commented 5 years ago

I run zig build run as per the README.md and get the same error:

sdl-zig-demo/build.zig:15:22: error: no member named 'addCommand' in struct 'std.build.Builder'
    const run_cmd = b.addCommand(".", b.env_map,
                     ^

Using zig version 0.5.0

I can successfully build with command zig build if I comment out the last 5 lines in the build.zig file:

const Builder = @import("std").build.Builder;

pub fn build(b: *Builder) void {
    const mode = b.standardReleaseOptions();
    const exe = b.addExecutable("sdl-zig-demo", "src/main.zig");
    exe.setBuildMode(mode);
    exe.linkSystemLibrary("SDL2");
    exe.linkSystemLibrary("c");

    b.default_step.dependOn(&exe.step);
    b.installArtifact(exe);

    // const run = b.step("run", "Run the demo");
    // const run_cmd = b.addCommand(".", b.env_map,
    //     [][]const u8{exe.getOutputPath(), });
    // run.dependOn(&run_cmd.step);
    // run_cmd.step.dependOn(&exe.step);
}

I run the program with ./zig-cache/bin/sdl-zig-demo and get the expected result: the zig.bmp image drawn in a window.

rishavs commented 5 years ago

same issue. On zig 0.5.0

C:\Users\risharan\DevSpace\Zig\sdl-zig-demo-master\build.zig:15:22: error: no member named 'addCommand' in struct 'std.build.Builder'
    const run_cmd = b.addCommand(".", b.env_map,
                     ^
xyproto commented 4 years ago

Still an issue with zig version 0.5.0+9439bf380.