Open GregTurbo opened 1 week ago
Sorry it seems that I never tried explicitly setting the target as x86_64-linux. I get an error when I do that as well. Seems like only windows lets me set the target explicitly. I'm on NixOS but I can try a different distro when I have a chance,
The error:
/home/gregturbo/.cache/zig/p/1220f655fd57d8e10b5dbe7d99c45a0b9836a13cea085d75cd4c15f6e603a1fcb058/src/external/glfw/src/x11_platform.h:36:10: error: 'X11/Xcursor/Xcursor.h' file not found
#include <X11/Xcursor/Xcursor.h>
^~~~~~~~~~~~~~~~~~~~~~~~
/home/gregturbo/.cache/zig/p/1220f655fd57d8e10b5dbe7d99c45a0b9836a13cea085d75cd4c15f6e603a1fcb058/src/rglfw.c:73:10: note: in file included from /home/gregturbo/.cache/zig/p/1220f655fd57d8e10b5dbe7d99c45a0b9836a13cea085d75cd4c15f6e603a1fcb058/src/rglfw.c:73:
#include "external/glfw/src/init.c"
^
/home/gregturbo/.cache/zig/p/1220f655fd57d8e10b5dbe7d99c45a0b9836a13cea085d75cd4c15f6e603a1fcb058/src/external/glfw/src/init.c:28:10: note: in file included from /home/gregturbo/.cache/zig/p/1220f655fd57d8e10b5dbe7d99c45a0b9836a13cea085d75cd4c15f6e603a1fcb058/src/external/glfw/src/init.c:28:
#include "internal.h"
^
/home/gregturbo/.cache/zig/p/1220f655fd57d8e10b5dbe7d99c45a0b9836a13cea085d75cd4c15f6e603a1fcb058/src/external/glfw/src/internal.h:325:10: note: in file included from
/home/gregturbo/.cache/zig/p/1220f655fd57d8e10b5dbe7d99c45a0b9836a13cea085d75cd4c15f6e603a1fcb058/src/external/glfw/src/internal.h:325:
#include "platform.h"
^
/home/gregturbo/.cache/zig/p/1220f655fd57d8e10b5dbe7d99c45a0b9836a13cea085d75cd4c15f6e603a1fcb058/src/external/glfw/src/platform.h:81:11: note: in file included from
/home/gregturbo/.cache/zig/p/1220f655fd57d8e10b5dbe7d99c45a0b9836a13cea085d75cd4c15f6e603a1fcb058/src/external/glfw/src/platform.h:81:
#include "x11_platform.h"
For reference, this is the nix shell I'm building it with:
let
unstable = import (fetchTarball https://nixos.org/channels/nixos-unstable/nixexprs.tar.xz) { };
in
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
nativeBuildInputs = with pkgs.buildPackages; [
unstable.zig #0.13.0
SDL2
pkg-config
xorg.libX11
xorg.libXcursor
xorg.libXrandr
xorg.libXinerama
wayland
pulseaudioFull
unzip
libxkbcommon
glfw
];
}
trying on popOS without nix-shell gives me the same error as #139
I was getting similar errors. I'm on Windows and I don't have a Mac, so I don't have a straightforward solution for it. However, for Linux, I could get it to work by supplementing some libraries for X11. I believe GLFW needs them. So, I modified the zig-raylib\build.zig
and my project's build.zig
.
Make sure to have a local copy of zig-raylib. First, you will need the system libs and headers from this link: https://github.com/zig-gamedev/zig-gamedev/tree/main/libs/system-sdk
Then, in raylib-zig\build.zig
, add these:
exe.addLibraryPath(b.path("../system-sdk/linux/lib/x86_64-linux-gnu")); // add this, line 80s
exe.linkSystemLibrary("GL");
exe.linkSystemLibrary("rt");
exe.linkSystemLibrary("dl");
exe.linkSystemLibrary("m");
exe.linkSystemLibrary("X11");
const lib = raylib.artifact("raylib");
lib.addLibraryPath(b.path("../system-sdk/linux/lib/x86_64-linux-gnu")); // add, line 110s
lib.addSystemIncludePath(b.path("../system-sdk/linux/include")); // add
And in your project's build.zig
, add this line:
const exe = b.addExecutable(.{});
exe.addLibraryPath(b.path("libs/system-sdk/linux/lib/x86_64-linux-gnu")); // add this too
You will also need to build with GNU: zig build -Dtarget=x86_64-linux-gnu
Making these modifications allows me to build on Linux. I test it through VMs (PopOS), WSL (Ubuntu), and cross-compile to Linux on Windows.
There are also Mac libraries and frameworks in the link above. I have not tested them, though.
Thanks, that works for me on Linux. Unfortunately the problem with macos is that I still can't get it to search any paths at all for the sdk
ok well it compiles with x86_64-linux and x86_linux-gnu but now I get this error trying to launch it:
INFO: Initializing raylib 5.5-dev
INFO: Platform backend: DESKTOP (GLFW)
INFO: Supported raylib modules:
INFO: > rcore:..... loaded (mandatory)
INFO: > rlgl:...... loaded (mandatory)
INFO: > rshapes:... loaded (optional)
INFO: > rtextures:. loaded (optional)
INFO: > rtext:..... loaded (optional)
INFO: > rmodels:... loaded (optional)
INFO: > raudio:.... loaded (optional)
WARNING: GLFW: Error: 65544 Description: X11: Failed to load Xlib
WARNING: GLFW: Failed to initialize GLFW
Segmentation fault at address 0x0
???:?:?: 0x0 in ??? (???)
Aborted (core dumped)
Never seen it before, I had a fully working and finished app when it was running without an explicit target but I'm about ready to give up on raylib/raygui at this point lol
I feel you. I have been experimenting with raylib for the last month. I think I have seen that error once. I have not used raygui, but my guess is that the problem is related to raygui.
Forgive me if this is a zig issue, but I've tried everything I can think of to make this work on my end.
zig version 0.13.0
I've tried on Linux, Monterey 12.7.6, and Sonoma (through a VM), all x86.
No matter which module I add a framework path to in my build.zig (Raylib, root_module, etc.), the searched paths in the error is always "none". I don't know where in the chain this search is happening but I haven't managed to get this to change.
I tried SDL and RGFW backends via "addCMacro".
To reproduce:
zig build -Dtarget=x86_64-macos
(or-Dtarget=aarch64-macos
)When the target is not defined and I'm on macOS, it compiles, though I don't know how compatible it is with other OS versions. I'm unable to try compiling natively for aarch64 as I don't have access to any apple silicon devices. My goal is to compile for both via github actions so manually compiling on native hardware is not ideal
The error: