deltaphc / raylib-rs

Rust bindings for raylib
Other
715 stars 123 forks source link

Problem when building with cross #197

Open samsvp opened 6 days ago

samsvp commented 6 days ago

Trying to cross compile from Ubuntu 20.04 to Windows with cross gives me the following error:

  --- stderr
  binding/../raylib/src/raylib.h:197:14: fatal error: 'stdbool.h' file not found
  thread 'main' panicked at /home/kubo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/raylib-sys-5.0.0/build.rs:211:39:
  Unable to generate bindings: ClangDiagnostic("binding/../raylib/src/raylib.h:197:14: fatal error: 'stdbool.h' file not found\n")
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I ran the command on the README

cross build --target x86_64-pc-windows-gnu --release

Full output

   Compiling raylib-sys v5.0.0
error: failed to run custom build command for `raylib-sys v5.0.0`

Caused by:
  process didn't exit successfully: `/target/release/build/raylib-sys-10e1fa08b645f742/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-changed=build.rs
  cargo:rerun-if-changed=./binding/binding.h
  CMAKE_TOOLCHAIN_FILE_x86_64-pc-windows-gnu = None
  CMAKE_TOOLCHAIN_FILE_x86_64_pc_windows_gnu = Some("/opt/toolchain.cmake")
  CMAKE_GENERATOR_x86_64-pc-windows-gnu = None
  CMAKE_GENERATOR_x86_64_pc_windows_gnu = None
  TARGET_CMAKE_GENERATOR = None
  CMAKE_GENERATOR = None
  CMAKE_PREFIX_PATH_x86_64-pc-windows-gnu = None
  CMAKE_PREFIX_PATH_x86_64_pc_windows_gnu = None
  TARGET_CMAKE_PREFIX_PATH = None
  CMAKE_PREFIX_PATH = None
  CMAKE_x86_64-pc-windows-gnu = None
  CMAKE_x86_64_pc_windows_gnu = None
  TARGET_CMAKE = None
  CMAKE = None
  running: cd "/target/x86_64-pc-windows-gnu/release/build/raylib-sys-d7ead76cbee58896/out/build" && CMAKE_PREFIX_PATH="" "cmake" "/target/x86_64-pc-windows-gnu/release/build/raylib-sys-d7ead76cbee58896/out/raylib" "-DCMAKE_BUILD_TYPE=Release" "-DBUILD_EXAMPLES=OFF" "-DCMAKE_BUILD_TYPE=Release" "-DSUPPORT_BUSY_WAIT_LOOP=OFF" "-DSUPPORT_FILEFORMAT_JPG=ON" "-DRAYMATH_STATIC_INLINE=ON" "-DUSE_WAYLAND=OFF" "-DOPENGL_VERSION=OFF" "-DPLATFORM=Desktop" "-DCMAKE_TOOLCHAIN_FILE=/opt/toolchain.cmake" "-DCMAKE_INSTALL_PREFIX=/target/x86_64-pc-windows-gnu/release/build/raylib-sys-d7ead76cbee58896/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -m64" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -m64" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -m64"
  -- 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
  -- Including Win32 support
  -- Audio Backend: miniaudio
  -- Building raylib static library
  -- Generated build type: Release
  -- Compiling with the flags:
  --   PLATFORM=PLATFORM_DESKTOP
  --   GRAPHICS=GRAPHICS_API_OPENGL_33
  -- Configuring done
  -- Generating done
  -- Build files have been written to: /target/x86_64-pc-windows-gnu/release/build/raylib-sys-d7ead76cbee58896/out/build
  running: cd "/target/x86_64-pc-windows-gnu/release/build/raylib-sys-d7ead76cbee58896/out/build" && MAKEFLAGS="-j --jobserver-fds=8,9 --jobserver-auth=8,9" "cmake" "--build" "." "--target" "install" "--config" "Release"
  Consolidate compiler generated dependencies of target glfw
  [ 73%] Built target glfw
  Consolidate compiler generated dependencies of target raylib
  [100%] Built target raylib
  Install the project...
  -- Install configuration: "Release"
  -- Up-to-date: /target/x86_64-pc-windows-gnu/release/build/raylib-sys-d7ead76cbee58896/out/lib/libraylib.a
  -- Up-to-date: /target/x86_64-pc-windows-gnu/release/build/raylib-sys-d7ead76cbee58896/out/include/raylib.h
  -- Up-to-date: /target/x86_64-pc-windows-gnu/release/build/raylib-sys-d7ead76cbee58896/out/include/rlgl.h
  -- Up-to-date: /target/x86_64-pc-windows-gnu/release/build/raylib-sys-d7ead76cbee58896/out/include/raymath.h
  -- Up-to-date: /target/x86_64-pc-windows-gnu/release/build/raylib-sys-d7ead76cbee58896/out/lib/pkgconfig/raylib.pc
  -- Up-to-date: /target/x86_64-pc-windows-gnu/release/build/raylib-sys-d7ead76cbee58896/out/lib/cmake/raylib/raylib-config-version.cmake
  -- Up-to-date: /target/x86_64-pc-windows-gnu/release/build/raylib-sys-d7ead76cbee58896/out/lib/cmake/raylib/raylib-config.cmake
  cargo:root=/target/x86_64-pc-windows-gnu/release/build/raylib-sys-d7ead76cbee58896/out
  cargo:rustc-link-search=native=/target/x86_64-pc-windows-gnu/release/build/raylib-sys-d7ead76cbee58896/out/lib

  --- stderr
  binding/../raylib/src/raylib.h:197:14: fatal error: 'stdbool.h' file not found
  thread 'main' panicked at /home/kubo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/raylib-sys-5.0.0/build.rs:211:39:
  Unable to generate bindings: ClangDiagnostic("binding/../raylib/src/raylib.h:197:14: fatal error: 'stdbool.h' file not found\n")
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Can I link C's stdlib to cross?

jackskelt commented 2 days ago

I found a solution. Create a Cross.toml and add a pre-build script for installing clang

[target.x86_64-pc-windows-gnu]
pre-build = [ 
    "apt-get update && apt-get --assume-yes install clang",
]