#project compile, but doesn't produce an exe anymore (windows)

1 messages · Page 1 of 1 (latest)

slender echo
#

Using master, 0.10
It was fine using master from last week
did something change in the builg.zig API that i need to change?

fn create_exe(b: *Builder, target: Target, mode: std.builtin.Mode, name: []const u8, source: []const u8, kind: Kind) !void {
    const exe = b.addExecutable(name, source);
    exe.want_lto = false;

    exe.setTarget(target);
    exe.setBuildMode(mode);
    exe.setOutputDir("bin/");

    const rt = Pkg { .name = "rt", .source = .{ .path = "projects/libs/rt/rt.zig" } };
    const dawn = Pkg { .name = "dawn", .source = .{ .path = "projects/libs/dawn/dawn.zig" }, .dependencies = &.{ rt} };
    const shared = Pkg { .name = "shared", .source = .{ .path = "projects/shared/shared.zig" }, .dependencies = &.{ rt, dawn } };

    exe.addPackage(rt);
    exe.addPackage(dawn);
    exe.addPackage(shared);

    exe.linkLibC();

    // various C stuff, cut off for this discord msg

    const run_cmd = exe.run();
    run_cmd.step.dependOn(b.getInstallStep());

    const run_step = b.step(name, b.fmt("run {s}", .{name}));
    run_step.dependOn(&run_cmd.step);
}
#

also notice the various undefined symbol errors, the release was rushed

boreal star
lapis haven
#

does it produce an exe if you $ zig build install?

boreal star
#

zig build and zig build install are identical

#

its not emitting an exe because theres a link error

lapis haven
#

i thought there was a recent change making zig build only update the cache while install is needed to output to zig-out

#

oic nevermind then

boreal star
#

now that is something to consider though, because there isn't a exe.install() anywhere here either (which would install the exe to zig-out)

#

run_cmd.step.dependOn(b.getInstallStep()); seems backwards,
this means that run_cmd depends on the default install step (which does nothing when there are no objects registered to be installed)

slender echo
slender echo
#

without it it doesn't do anything, still no exe

boreal star
boreal star
#

otherwise just do exe.install() and then it will be installed in zig-out whenever you run zig build install

slender echo
#

i'm not sure i understand that

#
    const run_cmd = exe.run();
    run_cmd.step.dependOn(b.getInstallStep());

    const run_step = b.step(name, b.fmt("run {s}", .{name}));
    run_step.dependOn(&run_cmd.step);

what needs to be changed here?

boreal star
#
exe.install();

const run_cmd = exe.run();

const run_step = b.step(...);
run_step.dependOn(&run_cmd.step);

will run the step whenever you do zig build thing
and will install the binary into zig-out when you do zig build install

slender echo
#

and i don't understand why it needs to be changed, it was working before

#
    exe.install();

    const run_cmd = exe.run();

    const run_step = b.step(name, b.fmt("run {s}", .{name}));
    run_step.dependOn(&run_cmd.step);

it still doesn't create the exe

#

i'll try delete the cache

#

same:
Unable to spawn bin\game.exe: FileNotFound
error: FileNotFound

boreal star
#

any other errors?

slender echo
#

here the full output

boreal star
#

you're still not compiling mongoose into your code

#

you add the headers, but not the actual code

slender echo
#

oh actually i'm stupid

#

that's that error that's preventing it to generate the exe..

#

2am brain is not working

#

actually that mean it's a zig build bug, since it shouldn't try to run what failed to compile

#

and the next issue is why it still complain about undefined symbol after adding the source

boreal star
#

are all of those symbols defined in that file?

slender echo
#

looks like i had a missing define, i'm now advancing

LLD Link... lld-link: error: duplicate symbol: sprintf_s
>>> defined at msvcrt-os.lib(sprintf_s.obj)
>>> defined at libcrypto.lib(libcrypto-lib-bio_addr.obj)

seems like that's the last error i get

#

how do i pass stuff to the linker? --allow-multiple-definition

boreal star
#

-Wl, in the flags like normal, but zig might not allow it

slender echo
#

i'm not sure i understand, what do you mean "in the flags"?

#

in the build file

boreal star
#

the same way you pass -std

slender echo
#

i never pass -std, i don't understand

boreal star
#

exe.addCSourceFile("projects/c/glad/glad.c", &.{"-std=c11"});

slender echo
#

oh this

boreal star
#

you can't really control what linker flags affect the whole unit, definitely not --allow-multiple-definition

slender echo
#
Semantic Analysis... comptime_0... error(compilation): clang failed with stderr: zig: error: unknown argument: '-wl--allow-multiple-definition'
boreal star
#

you're not supposed to have multiple definitions for the same symbol

#

I'd recommend finding out why libcrypto is exporting sprintf

slender echo
#

it's a static build

#

it's the same library i use in my other project, i haven't changed anything

#

built using vcpkg

#

that's why i don't like C/C++, bloated workflow i hate it

#

and now zig complains