deltaphc / raylib-rs

Rust bindings for raylib
Other
741 stars 133 forks source link

Running on NixOS fails. #144

Open GalladeR475 opened 1 year ago

GalladeR475 commented 1 year ago

ISSUE Running cargo run on a raylib-rs project errors while installing glfw, curl and cmake on NixOS. ERROR error: failed to run custom build command for raylib-sys v3.7.0

Caused by: process didn't exit successfully: /home/USER/Documents/trackter/target/debug/build/raylib-sys-99612b4e7597fe84/build-script-build (exit status: 101) --- stdout CMAKE_TOOLCHAIN_FILE_x86_64-unknown-linux-gnu = None CMAKE_TOOLCHAIN_FILE_x86_64_unknown_linux_gnu = None HOST_CMAKE_TOOLCHAIN_FILE = None CMAKE_TOOLCHAIN_FILE = None CMAKE_GENERATOR_x86_64-unknown-linux-gnu = None CMAKE_GENERATOR_x86_64_unknown_linux_gnu = None HOST_CMAKE_GENERATOR = None CMAKE_GENERATOR = None CMAKE_PREFIX_PATH_x86_64-unknown-linux-gnu = None CMAKE_PREFIX_PATH_x86_64_unknown_linux_gnu = None HOST_CMAKE_PREFIX_PATH = None CMAKE_PREFIX_PATH = None CMAKE_x86_64-unknown-linux-gnu = None CMAKE_x86_64_unknown_linux_gnu = None HOST_CMAKE = None CMAKE = None running: "cmake" "/home/USER/Documents/trackter/target/debug/build/raylib-sys-b50135bb1e6abfc1/out/raylib" "-DBUILD_EXAMPLES=OFF" "-DCMAKE_BUILD_TYPE=Release" "-DSUPPORT_BUSY_WAIT_LOOP=OFF" "-DPLATFORM=Desktop" "-DCMAKE_INSTALL_PREFIX=/home/USER/Documents/trackter/target/debug/build/raylib-sys-b50135bb1e6abfc1/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_C_COMPILER=/etc/profiles/per-user/USER/bin/cc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_CXX_COMPILER=/etc/profiles/per-user/rishabht/bin/c++" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_ASM_COMPILER=/etc/profiles/per-user/USER/bin/cc" -- Testing if -Werror=pointer-arith can be used -- compiles -- Testing if -Werror=implicit-function-declaration can be used -- compiles -- Testing if -fno-strict-aliasing can be used -- compiles -- Using raylib's GLFW -- Using X11 for window creation -- Configuring incomplete, errors occurred! See also "/home/USER/Documents/trackter/target/debug/build/raylib-sys-b50135bb1e6abfc1/out/build/CMakeFiles/CMakeOutput.log".

--- stderr CMake Error at /nix/store/c5b6rbqxmvf447qvlswk6sxgl6cy1vky-cmake-3.22.3/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message): Could NOT find X11 (missing: X11_X11_INCLUDE_PATH X11_X11_LIB) Call Stack (most recent call first): /nix/store/c5b6rbqxmvf447qvlswk6sxgl6cy1vky-cmake-3.22.3/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE) /nix/store/c5b6rbqxmvf447qvlswk6sxgl6cy1vky-cmake-3.22.3/share/cmake-3.22/Modules/FindX11.cmake:457 (find_package_handle_standard_args) src/external/glfw/CMakeLists.txt:204 (find_package)

thread 'main' panicked at ' command did not execute successfully, got: exit status: 1

build script failed, must exit now', /home/USER/.cargo/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.49/src/lib.rs:1104:5 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

ChildishGiant commented 1 year ago

I had a similar error on fedora 37 but it turns out I just needed the dependencies: https://github.com/raysan5/raylib/wiki/Working-on-GNU-Linux#install-required-libraries

GalladeR475 commented 1 year ago

I somehow figured it out, but I had to compile again due to version mismatch i.e. OpenGL was 3.0 on my linux machine, so I had to re-compile it with a lower version of OpenGL

boblehest commented 10 months ago

My experience running this on NixOS: Adding dependencies or changing versions of OpenGL (via the raylib-sys feature flags opengl_*) did not help for me. What did help was to pass USE_EXTERNAL_GLFW=ON when building raylib (by patching raylib-sys/build.rs where I also added println!("cargo:rustc-link-lib=glfw"); even if wayland is not enabled).