Turning off wayland for raylib's zig build?

This is exactly what i was struggling to figure out. The process went: i thought i was dumb and doing something wrong, i tried a bunch of seemingly silly things which i suspected wouldnt work and indeed did not work, and then i started to think “wait is this an actual bug upstream?” but i never got to the bottom of that before i messed with my host system too much (installing libraries and upgrading zig) to where i got the build working.

But yes, im still suspecting that setting .linux_display_backend = .X11, like i was SHOULD have solved the problem for me (where it shouldn’t try to build in wayland support) but it was infact still trying to build with wayland support and so i was hitting the branch where it throws the compiler error because wayland libraries couldn’t be found. which seemed wrong to me?

it doesn’t help that the compiler error thrown shows an example that doesn’t align with actual code changes you need to make either :man_facepalming:

Here is an example based on your build.zig and build.zig.zon GitHub - SimonLSchlee/reproducewaylanderror

This compiles and runs for me, can you check whether this works for you, or causes the error on your setup?

I currently don’t have a quick way to remove all wayland things to check whether it compiles without it.

pav@linux:~/git/open-source/reproducewaylanderror$ zig build run
run
└─ run raylib-game
   └─ install
      └─ install raylib-game
         └─ zig build-exe raylib-game Debug native failure
error: warning(link): unexpected LLD stderr:
ld.lld: warning: /home/pav/git/open-source/reproducewaylanderror/.zig-cache/o/2f1d7949edca1b14c9625097eb61c7ae/libraylib.a: archive member '/usr/lib/x86_64-linux-gnu/libGLX.so' is neither ET_REL nor LLVM bitcode
ld.lld: warning: /home/pav/git/open-source/reproducewaylanderror/.zig-cache/o/2f1d7949edca1b14c9625097eb61c7ae/libraylib.a: archive member '/usr/lib/x86_64-linux-gnu/libX11.so' is neither ET_REL nor LLVM bitcode
ld.lld: warning: /home/pav/git/open-source/reproducewaylanderror/.zig-cache/o/2f1d7949edca1b14c9625097eb61c7ae/libraylib.a: archive member '/usr/lib/x86_64-linux-gnu/libXcursor.so' is neither ET_REL nor LLVM bitcode
ld.lld: warning: /home/pav/git/open-source/reproducewaylanderror/.zig-cache/o/2f1d7949edca1b14c9625097eb61c7ae/libraylib.a: archive member '/usr/lib/x86_64-linux-gnu/libXext.so' is neither ET_REL nor LLVM bitcode
ld.lld: warning: /home/pav/git/open-source/reproducewaylanderror/.zig-cache/o/2f1d7949edca1b14c9625097eb61c7ae/libraylib.a: archive member '/usr/lib/x86_64-linux-gnu/libXfixes.so' is neither ET_REL nor LLVM bitcode
ld.lld: warning: /home/pav/git/open-source/reproducewaylanderror/.zig-cache/o/2f1d7949edca1b14c9625097eb61c7ae/libraylib.a: archive member '/usr/lib/x86_64-linux-gnu/libXi.so' is neither ET_REL nor LLVM bitcode
ld.lld: warning: /home/pav/git/open-source/reproducewaylanderror/.zig-cache/o/2f1d7949edca1b14c9625097eb61c7ae/libraylib.a: archive member '/usr/lib/x86_64-linux-gnu/libXinerama.so' is neither ET_REL nor LLVM bitcode
ld.lld: warning: /home/pav/git/open-source/reproducewaylanderror/.zig-cache/o/2f1d7949edca1b14c9625097eb61c7ae/libraylib.a: archive member '/usr/lib/x86_64-linux-gnu/libXrandr.so' is neither ET_REL nor LLVM bitcode
ld.lld: warning: /home/pav/git/open-source/reproducewaylanderror/.zig-cache/o/2f1d7949edca1b14c9625097eb61c7ae/libraylib.a: archive member '/usr/lib/x86_64-linux-gnu/libXrender.so' is neither ET_REL nor LLVM bitcode
ld.lld: warning: /home/pav/git/open-source/reproducewaylanderror/.zig-cache/o/2f1d7949edca1b14c9625097eb61c7ae/libraylib.a: archive member '/usr/lib/x86_64-linux-gnu/libX11.so' is neither ET_REL nor LLVM bitcode

some warnings, but it does compile and run

but im in the same boat as you. I can’t figure out how to get my machine back into the original state i had the error :sweat_smile: just doing a sudo apt remove libwayland-dev doesn’t get me back to the original error even though that is absolutely the library in installed that help fix the error

1 Like

Maybe you forgot to save and you got the error thinking you added the option, when the file wasn’t actually saved yet?

Because when looking at how it is implemented I just don’t understand how the code would get there if the option is .X11

Me being that silly is absolutely possible. However i would say its unlikely in this situation because of how many code changes i made trying to fix the error! the first few posts and replies in this thread show i tried atleast 3 different ways to set the flag, and every time i did that i was deleting the .zig-cache and rebuilding.

and just to summarize the ways i tried:
.linux_display_backend = .X11
.linux_display_backend = raylib_build.LinuxDisplayBackend.X11
raylib_dependency.builder.addUserInputOption("linux_display_backend", "X11")
_ = b.addUserInputOption("linux_display_backend", "X11") catch unreachable

and then on the cli too with:
zig build -Dlinux_display_backend=X11

none of them worked and all resulted in the same error, which means i was inside the branch that means my option was set to .Both

I guess the last thing i can try is how would i go about verifying that setting .X11 does indeed not compile in support for wayland? Thats kind of what i was trying to get at by instead setting the option to .Wayland but i guess i misunderstood what that does.

How can i verify that raylib gets compiled respecting my option i set from my build.zig file?

I often get myself with the silliest mistakes where I edit 3 files save them, but then edit the 4th and forget to save it.

But yeah difficult to say what it was exactly and until we get the error again, we are kind of lost.

Did you change raylib versions in between or did you stay on that single commit for the entire time, we also should look at that specific commit to see if there is anything different than in raylib master.

Yeah see this is another example of me being silly, i was changing versions and commits all over the place. and i was often making more than one change at a time because you know, that seems logical :grimacing: the very first attempt where i hit the error i was on zig 0.13.0 and raylib tag 5.5 and raygui tag 4.0. i slowly started changing all those versions as i was changing my build.zig too trying to stumble my way into a solution, lol.

But yes i think im at the point now where i’ve managed to get myself into a place that i can no longer continue to see if this is an actual issue or a user error because i dont have the error now. I guess if one day somebody stumbles upon this thread with the same error they can please tag me so we can continue down the road a bit further?

FWIW if it was a host library issue im on Linux Mint Debian Edition 6 “Faye”

1 Like

That is a good question, but I am not sure what the easiest way would be, I wonder whether there is some way to get raylib to print what is compiled into it.

If there is nothing like that, than the only way is probably to run it as a wayland application and then see it fail, but I currently don’t have a setup where I run wayland.

Yes I think lets just continue when / if somebody can reproduce it.

I don’t really understand what these warnings are that you are getting,
they didn’t appear on my system (I am on manjaro),
but I think that might be a whole other issue.