Content-Length: 278038 | pFad | https://github.com/zig-gamedev/zig-gamedev/issues/751

5E glfw PlatformError when running glfw examples · Issue #751 · zig-gamedev/zig-gamedev · GitHub
Skip to content

glfw PlatformError when running glfw examples #751

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
MaxCross2500 opened this issue Apr 20, 2025 · 4 comments
Open

glfw PlatformError when running glfw examples #751

MaxCross2500 opened this issue Apr 20, 2025 · 4 comments

Comments

@MaxCross2500
Copy link

MaxCross2500 commented Apr 20, 2025

On nixos (had to use nix-shell with xorg.libX11 so libX11.so.6 would get resolved).
(I used upgrade-zig branch (14758e6).

~/projects/external/zig-gamedev> nix-shell --command 'zig build triangle_wgpu-run'                                                                                                                                                                             20/04/25 11:42:07
anyzig: zig version '0.14.0' pulled from '/home/maxcross/projects/external/zig-gamedev/build.zig.zon'
anyzig: appdata '/home/maxcross/.local/share/anyzig'
anyzig: zig '0.14.0' already exists at '/home/maxcross/.cache/zig/p/N-V-__8AANS1ihIOtIbwStI19vHd9274HDAeXLQjJFgZzdsY'
triangle_wgpu-run
└─ run triangle_wgpu
   └─ install triangle_wgpu
      └─ zig build-exe triangle_wgpu Debug native failure
error: warning(link): unexpected LLD stderr:
ld.lld: warning: /home/maxcross/projects/external/zig-gamedev/.zig-cache/o/4704c49b95416ed5f58f87f2639195a3/libglfw.a: archive member '/home/maxcross/.cache/zig/p/system_sdk-0.3.0-dev-alwUNnYaaAJAtIdE2fg4NQfDqEKs7QCXy_qYukAOBfmF/linux/lib/x86_64-linux-gnu/libX11.so' is neither ET_REL nor LLVM bitcode
ld.lld: warning: /home/maxcross/projects/external/zig-gamedev/.zig-cache/o/0bfab639417153c35d0264b935decc0a/libzdawn.a: archive member '/home/maxcross/.cache/zig/p/N-V-__8AAK7XUQNKNRnv1J6i189jtURJKjp3HTftoyD4Y4CB/libdawn.a' is neither ET_REL nor LLVM bitcode


error: PlatformError
/home/maxcross/.cache/zig/p/zglfw-0.10.0-dev-zgVDNG2cIQAiAC_gLYmbML-NQklPW5B_AELV_fAQc2Jg/src/zglfw.zig:118:5: 0x13be728 in convertError (triangle_wgpu)
    return switch (e) {
    ^
/home/maxcross/.cache/zig/p/zglfw-0.10.0-dev-zgVDNG2cIQAiAC_gLYmbML-NQklPW5B_AELV_fAQc2Jg/src/zglfw.zig:139:5: 0x13ae1fc in maybeError (triangle_wgpu)
    return convertError(glfwGetError(null));
    ^
/home/maxcross/.cache/zig/p/zglfw-0.10.0-dev-zgVDNG2cIQAiAC_gLYmbML-NQklPW5B_AELV_fAQc2Jg/src/zglfw.zig:54:5: 0x13abeff in init (triangle_wgpu)
    try maybeError();
    ^
/home/maxcross/projects/external/zig-gamedev/samples/triangle_wgpu/src/triangle_wgpu.zig:324:5: 0x13ab9a6 in main (triangle_wgpu)
    try zglfw.init();
    ^
triangle_wgpu-run
└─ run triangle_wgpu failure
error: the following command exited with error code 1:
/home/maxcross/projects/external/zig-gamedev/zig-out/bin/triangle_wgpu 
Build Summary: 14/16 steps succeeded; 1 failed
triangle_wgpu-run transitive failure
└─ run triangle_wgpu failure
error: the following build command failed with exit code 1:
/home/maxcross/projects/external/zig-gamedev/.zig-cache/o/fdfa34f30e73618405e001b4e6018c11/build /home/maxcross/.cache/zig/p/N-V-__8AANS1ihIOtIbwStI19vHd9274HDAeXLQjJFgZzdsY/zig /home/maxcross/.cache/zig/p/N-V-__8AANS1ihIOtIbwStI19vHd9274HDAeXLQjJFgZzdsY/lib /home/maxcross/projects/external/zig-gamedev /home/maxcross/projects/external/zig-gamedev/.zig-cache /home/maxcross/.cache/zig --seed 0x112671d6 -Z89c0f83fe7d67ea6 triangle_wgpu-run
@MaxCross2500
Copy link
Author

MaxCross2500 commented Apr 20, 2025

Probably unrelated, but disabling x11 when importing zglfw in triangle_wgpu sample gives me linker error.

    const zglfw = b.dependency("zglfw", .{
        .target = options.target,
        .x11 = false,
    });
error: ld.lld: 
error: ld.lld: undefined symbol: XSetErrorHandler
    note: referenced by Surface.cpp
    note:               /home/runner/work/mach-gpu-dawn/mach-gpu-dawn/zig-cache/o/97558059d6bd8e1e7980a87ad6ea612e/Surface.o:(dawn::native::ValidateSurfaceDescriptor(dawn::native::InstanceBase const*, dawn::native::SurfaceDescriptor const*)) in archive /home/maxcross/.cache/zig/p/N-V-__8AAK7XUQNKNRnv1J6i189jtURJKjp3HTftoyD4Y4CB/libdawn.a
    note: referenced by Surface.cpp
    note:               /home/runner/work/mach-gpu-dawn/mach-gpu-dawn/zig-cache/o/97558059d6bd8e1e7980a87ad6ea612e/Surface.o:(dawn::native::ValidateSurfaceDescriptor(dawn::native::InstanceBase const*, dawn::native::SurfaceDescriptor const*)) in archive /home/maxcross/.cache/zig/p/N-V-__8AAK7XUQNKNRnv1J6i189jtURJKjp3HTftoyD4Y4CB/libdawn.a
error: ld.lld: undefined symbol: XGetWindowAttributes
    note: referenced by Surface.cpp
    note:               /home/runner/work/mach-gpu-dawn/mach-gpu-dawn/zig-cache/o/97558059d6bd8e1e7980a87ad6ea612e/Surface.o:(dawn::native::ValidateSurfaceDescriptor(dawn::native::InstanceBase const*, dawn::native::SurfaceDescriptor const*)) in archive /home/maxcross/.cache/zig/p/N-V-__8AAK7XUQNKNRnv1J6i189jtURJKjp3HTftoyD4Y4CB/libdawn.a

(on opengl examples doing this still produces platform error, but now the executable doesn't depend on libX11)

@MaxCross2500
Copy link
Author

It's a completely different errors if I switch from wayland session to x11:

Warning: Couldn't load Vulkan. Searched /home/maxcross/projects/external/zig-gamedev/zig-out/bin/libvulkan.so.1, /home/maxcross/projects/external/zig-gamedev/zig-out/bin/libvulkan.so.1, libvulkan.so.1.
    at operator() (/home/runner/work/mach-gpu-dawn/mach-gpu-dawn/libs/dawn/src/dawn/native/vulkan/BackendVk.cpp:265)
    at Initialize (/home/runner/work/mach-gpu-dawn/mach-gpu-dawn/libs/dawn/src/dawn/native/vulkan/BackendVk.cpp:270)
    at Create (/home/runner/work/mach-gpu-dawn/mach-gpu-dawn/libs/dawn/src/dawn/native/vulkan/BackendVk.cpp:232)
    at operator() (/home/runner/work/mach-gpu-dawn/mach-gpu-dawn/libs/dawn/src/dawn/native/vulkan/BackendVk.cpp:479)

info: [zgpu] High-performance device has been selected:
info: [zgpu]   Name: Null backend
info: [zgpu]   Driver: 
info: [zgpu]   Adapter type: cpu
info: [zgpu]   Backend type: nul
Error: Invalid X Window
    at ValidateSurfaceDescriptor (/home/runner/work/mach-gpu-dawn/mach-gpu-dawn/libs/dawn/src/dawn/native/Surface.cpp:161)

error: [zgpu] Validation: [Surface] is invalid.
 - While validating [SwapChainDescriptor "zig-gamedev-gctx-swapchain"]
 - While calling [Device].CreateSwapChain([SwapChainDescriptor "zig-gamedev-gctx-swapchain"]).

And if I add vulkan-headers, vulkan-loader to nix-shell:

Warning: terminator_CreateInstance: Received return code -3 from call to vkCreateInstance in ICD /nix/store/bhp0fdci3f662hiklc074nw13i0xyd1f-mesa-24.2.8-drivers/lib/libvulkan_dzn.so. Skipping this driver.
info: [zgpu] High-performance device has been selected:
info: [zgpu]   Name: NVIDIA GeForce RTX 4080
info: [zgpu]   Driver: NVIDIA: 565.77 565.77.0.0
info: [zgpu]   Adapter type: discrete_gpu
info: [zgpu]   Backend type: vulkan
Error: Invalid X Window
    at ValidateSurfaceDescriptor (/home/runner/work/mach-gpu-dawn/mach-gpu-dawn/libs/dawn/src/dawn/native/Surface.cpp:161)

error: [zgpu] Validation: [Surface] is invalid.
 - While validating [SwapChainDescriptor "zig-gamedev-gctx-swapchain"]
 - While calling [Device].CreateSwapChain([SwapChainDescriptor "zig-gamedev-gctx-swapchain"]).

@MaxCross2500
Copy link
Author

Solved by setting up error callback (zglfw.setErrorCallback), and realizing that I need libxkbcommon and vulkan-loader in my nix-shell.
Not obvious at all, but at least now I now some way to troubleshoot this.
Now my cursor doesn't align with imgui buttons, but that a sepparate problem - at least it runs.

@hazeycode
Copy link
Member

hazeycode commented May 1, 2025

Thanks for documenting, this might be useful to other nix users. I will leave this open and look to improve the experience.

As for cursor alignment, we have some issues with DPI scaling, please see zig-gamedev/zgui#34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/zig-gamedev/zig-gamedev/issues/751

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy