macOS: mach-glfw fails to build with "unrecognized file extension of parameter" #82

Closed
opened 2021-11-20 06:39:17 +00:00 by kaikuehne · 3 comments
kaikuehne commented 2021-11-20 06:39:17 +00:00 (Migrated from github.com)

Hello, thanks for making this, and specifically mach-glfw.
After following the instructions over at hexops/mach-glfw,
I'm getting this error message when running zig build in my project directory:

error: unrecognized file extension of parameter '/Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/glfw/src/cocoa_joystick.m'
glfw...The following command exited with error code 1:
/usr/local/Cellar/zig/0.8.1_1/bin/zig build-lib /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/src/main.zig -cflags -D_GLFW_COCOA -- /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/glfw/src/cocoa_joystick.m /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/glfw/src/cocoa_init.m /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/glfw/src/cocoa_window.m /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/glfw/src/cocoa_time.c /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/glfw/src/cocoa_monitor.m /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/glfw/src/nsgl_context.m /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/glfw/src/posix_thread.c /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/glfw/src/monitor.c /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/glfw/src/init.c /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/glfw/src/vulkan.c /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/glfw/src/input.c /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/glfw/src/osmesa_context.c /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/glfw/src/egl_context.c /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/glfw/src/context.c /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/glfw/src/window.c -lc -lobjc --cache-dir /Users/kai/Desktop/test-zig-glfw/zig-cache --global-cache-dir /Users/kai/.cache/zig --name glfw -I /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/glfw/include -I /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/vulkan_headers/include -isystem /Users/kai/Library/Application Support/hexops/sdk-macos-11.3/root/usr/include -L /Users/kai/Library/Application Support/hexops/sdk-macos-11.3/root/usr/lib -F /Users/kai/Library/Application Support/hexops/sdk-macos-11.3/root/System/Library/Frameworks -framework CoreFoundation -framework IOKit -framework Metal -framework AppKit --enable-cache
error: the following build command failed with exit code 1:
/Users/kai/Desktop/test-zig-glfw/zig-cache/o/e9c19e6662dcdc3b60a5c83de2450890/build /usr/local/Cellar/zig/0.8.1_1/bin/zig /Users/kai/Desktop/test-zig-glfw /Users/kai/Desktop/test-zig-glfw/zig-cache /Users/kai/.cache/zig

The build.zig looks like this:

const std = @import("std");
const glfw = @import("libs/mach-glfw/build.zig");

pub fn build(b: *std.build.Builder) void {
    const exe = b.addExecutable("test-zig-glfw", "main.zig");
    exe.addPackagePath("glfw", "libs/mach-glfw/src/main.zig");
    glfw.link(b, exe, .{});
}
Darwin macmini.local 21.1.0 Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:23 PDT 2021; root:xnu-8019.41.5~1/RELEASE_X86_64 x86_64

Let me know if you need more information.
Please note that this is the very first time I have ever tried to build anything with zig, so I might have missed something crucial.

Hello, thanks for making this, and specifically mach-glfw. After following [the instructions](https://github.com/hexops/mach-glfw#getting-started) over at hexops/mach-glfw, I'm getting this error message when running `zig build` in my project directory: ```sh error: unrecognized file extension of parameter '/Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/glfw/src/cocoa_joystick.m' glfw...The following command exited with error code 1: /usr/local/Cellar/zig/0.8.1_1/bin/zig build-lib /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/src/main.zig -cflags -D_GLFW_COCOA -- /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/glfw/src/cocoa_joystick.m /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/glfw/src/cocoa_init.m /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/glfw/src/cocoa_window.m /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/glfw/src/cocoa_time.c /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/glfw/src/cocoa_monitor.m /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/glfw/src/nsgl_context.m /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/glfw/src/posix_thread.c /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/glfw/src/monitor.c /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/glfw/src/init.c /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/glfw/src/vulkan.c /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/glfw/src/input.c /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/glfw/src/osmesa_context.c /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/glfw/src/egl_context.c /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/glfw/src/context.c /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/glfw/src/window.c -lc -lobjc --cache-dir /Users/kai/Desktop/test-zig-glfw/zig-cache --global-cache-dir /Users/kai/.cache/zig --name glfw -I /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/glfw/include -I /Users/kai/Desktop/test-zig-glfw/libs/mach-glfw/upstream/vulkan_headers/include -isystem /Users/kai/Library/Application Support/hexops/sdk-macos-11.3/root/usr/include -L /Users/kai/Library/Application Support/hexops/sdk-macos-11.3/root/usr/lib -F /Users/kai/Library/Application Support/hexops/sdk-macos-11.3/root/System/Library/Frameworks -framework CoreFoundation -framework IOKit -framework Metal -framework AppKit --enable-cache error: the following build command failed with exit code 1: /Users/kai/Desktop/test-zig-glfw/zig-cache/o/e9c19e6662dcdc3b60a5c83de2450890/build /usr/local/Cellar/zig/0.8.1_1/bin/zig /Users/kai/Desktop/test-zig-glfw /Users/kai/Desktop/test-zig-glfw/zig-cache /Users/kai/.cache/zig ``` The build.zig looks like this: ```zig const std = @import("std"); const glfw = @import("libs/mach-glfw/build.zig"); pub fn build(b: *std.build.Builder) void { const exe = b.addExecutable("test-zig-glfw", "main.zig"); exe.addPackagePath("glfw", "libs/mach-glfw/src/main.zig"); glfw.link(b, exe, .{}); } ``` ```sh Darwin macmini.local 21.1.0 Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:23 PDT 2021; root:xnu-8019.41.5~1/RELEASE_X86_64 x86_64 ``` Let me know if you need more information. Please note that this is the very first time I have ever tried to build anything with zig, so I might have missed something crucial.
emidoots commented 2021-11-20 08:02:04 +00:00 (Migrated from github.com)

Hi, it looks like you are running Zig 0.8.1 - in order to use this library you'll need to use a recent Zig master version. You can brew uninstall zig and then brew install zig --HEAD

That should fix it :) Let me know if you still have any issues

Hi, it looks like you are running Zig 0.8.1 - in order to use this library you'll need to use a recent Zig `master` version. You can `brew uninstall zig` and then `brew install zig --HEAD` That should fix it :) Let me know if you still have any issues
kaikuehne commented 2021-11-20 13:03:09 +00:00 (Migrated from github.com)

Hello, it works now, thank you!

For other starters: I also forgot to add a line like exe.install(...) to the build file:

const std = @import("std");
const glfw = @import("libs/mach-glfw/build.zig");

pub fn build(b: *std.build.Builder) void {
    const exe = b.addExecutable("test-zig-glfw", "main.zig");
    exe.addPackagePath("glfw", "libs/mach-glfw/src/main.zig");
    glfw.link(b, exe, .{});
    exe.install();
}
Hello, it works now, thank you! For other starters: I also forgot to add a line like `exe.install(...)` to the build file: ```zig const std = @import("std"); const glfw = @import("libs/mach-glfw/build.zig"); pub fn build(b: *std.build.Builder) void { const exe = b.addExecutable("test-zig-glfw", "main.zig"); exe.addPackagePath("glfw", "libs/mach-glfw/src/main.zig"); glfw.link(b, exe, .{}); exe.install(); } ```
emidoots commented 2021-11-20 18:46:43 +00:00 (Migrated from github.com)

You can use zig init-exe and zig init-lib to create a skeleton Zig project, I highly recommend using that :) It'll help you get the other bits like adding cross-compilation flags to your build.zig for you

You can use `zig init-exe` and `zig init-lib` to create a skeleton Zig project, I highly recommend using that :) It'll help you get the other bits like adding cross-compilation flags to your `build.zig` for you
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
hexops/mach#82
No description provided.