-
Notifications
You must be signed in to change notification settings - Fork 438
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
can't find crate for vulkano_shaders
#2559
Comments
I suggest making a fresh crate and running it like this:
Because you aren't going to go far with that diagnostic that Rust outputs when a linker error happens when building a proc macro dependency. |
Thanks for being so quick to answer, sorry for being so slow. That succeeded:
I'm quite new at rust, so I'm unsure of what exactly is going wrong. |
I was expecting that to fail, actually, and show you the errors (which Rust doesn't display when compiling the proc macro). I don't know what to do now. |
Same issue here on NixOS 24.11 (Linux 6.10.9), when following the tutorial:
main.rs // ...
// LSP does show the crate and its contents.
// Running it throws the error.
use vulkano_shaders::shader;
mod vs {
shader! {
ty: "vertex",
src: r"
#version 460
layout(location = 0) in vec2 position;
void main() {
gl_Position = vec4(position, 0.0, 1.0);
}
",
}
}
// ... Cargo: 1.82.0 $ rustup default
stable-x86_64-unknown-linux-gnu (default) Cargo.toml: [package]
name = "name"
version = "0.1.0"
edition = "2021"
[dependencies]
vulkano = "0.34.0"
vulkano-shaders = "0.34.0"
# ... I run # Copyright (c) 2015-2023 LunarG, Inc.
# source this file into an existing shell to setup your environment.
#
# See docs for in depth documentation:
# https://vulkan.lunarg.com/doc/sdk/latest/linux/getting_started.html
ARCH="$(uname -m)"
VULKAN_SDK="$(dirname "$(readlink -f "${BASH_SOURCE:-$0}" )" )/$ARCH"
export VULKAN_SDK
PATH="$VULKAN_SDK/bin:$PATH"
export PATH
LD_LIBRARY_PATH="$VULKAN_SDK/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
export LD_LIBRARY_PATH
VK_ADD_LAYER_PATH="$VULKAN_SDK/share/vulkan/explicit_layer.d${VK_ADD_LAYER_PATH:+:$VK_ADD_LAYER_PATH}"
export VK_ADD_LAYER_PATH
if [ -n "${VK_LAYER_PATH-}" ]; then
echo "Unsetting VK_LAYER_PATH environment variable for SDK usage"
unset VK_LAYER_PATH
fi flake.nix: {
description = "Vulkan Dev Flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs =
{ self, nixpkgs }@inputs:
let
lib = nixpkgs.lib;
pkgs = import inputs.nixpkgs {
system = "x86_64-linux";
};
in
{
devShells.x86_64-linux.default = pkgs.mkShell rec {
name = "Test Env";
buildInputs = with pkgs; [
libxkbcommon
libGL
wayland
cmake
pkg-config
xorg.libX11
xorg.libXrandr
xorg.libXcursor
xorg.libXi
xorg.libXxf86vm
glfw3
glslang
fontconfig
spirv-tools
vulkan-volk
vulkan-tools
vulkan-loader
vulkan-headers
vulkan-validation-layers
vulkan-tools-lunarg
vulkan-extension-layer
];
LD_LIBRARY_PATH = "${lib.makeLibraryPath buildInputs}";
VK_LAYER_PATH = "${pkgs.vulkan-validation-layers}/share/vulkan/explicit_layer.d";
VULKAN_SDK = "${pkgs.vulkan-validation-layers}/share/vulkan/";
};
};
} |
@Oughie vulkano-shaders needs shaderc. I'm not seeing shaderc in your flake. |
@marc0246 Thank you, that did it for me ^^ |
@Oughie Hey, can you post the complete flake you're using to build/run a vulkano project on NixOS? Sounds like you got it working in the end. I've been able to make it work building shaderc from source, but not using shaderc from nixpkgs. |
@happenslol I adjusted the For some reason, only this specific order works for me: nix develop
source setup-env.sh # inside the VulkanSDK directory
# Compile other dependencies until the end/source code is reached (-> "vulkano_shaders" error occurs)
cargo build
nix develop
# Compile the remaining source code, including the "vulkano_shaders"-part
cargo build flake.nix:{
description = "Vulkan Dev Flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs =
{ self, nixpkgs }@inputs:
let
lib = nixpkgs.lib;
pkgs = import inputs.nixpkgs {
system = "x86_64-linux";
};
in
{
devShells.x86_64-linux.default = pkgs.mkShell rec {
name = "Test Env";
buildInputs = with pkgs; [
libxkbcommon
libGL
wayland
cmake
shaderc # NEW
pkg-config
xorg.libX11
xorg.libXrandr
xorg.libXcursor
xorg.libXi
xorg.libXxf86vm
glfw3
glslang
fontconfig
spirv-tools
vulkan-volk
vulkan-tools
vulkan-loader
vulkan-headers
vulkan-validation-layers
vulkan-tools-lunarg
vulkan-extension-layer
];
LD_LIBRARY_PATH = "${lib.makeLibraryPath buildInputs}";
VK_LAYER_PATH = "${pkgs.vulkan-validation-layers}/share/vulkan/explicit_layer.d";
VULKAN_SDK = "${pkgs.vulkan-validation-layers}/share/vulkan/";
};
};
} |
@Oughie May I ask why run that VulkanSDK shell script? Seems unnecessary given that your flake can (and already does) set up the environment variables. But also, how does it work without setting |
@marc0246 If I don't run the VulkanSDK script, the following error occurs: error: failed to run custom build command for `shaderc-sys v0.8.3`
Caused by:
process didn't exit successfully: `/some/path/target/debug/build/shaderc-sys-cee44ea4f2edcc8c/build-script-build` (exit status: 101)
--- stderr
thread 'main' panicked at /some/path/.cargo/registry/src/index.crates.io-6f17d22bba15001f/shaderc-sys-0.8.3/build/build.rs:205:59:
called `Result::unwrap()` on an `Err` value: "could not read vk.xml in $VULKAN_SDK: No such file or directory (os error 2)"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace Running But I found out adding the following line to my SHADERC_LIB_DIR = "${pkgs.shaderc}/libs"; |
Oh, I didn't know shaderc (the crate) searched using the |
Issue
I'm trying to run one of the examples. I have the repo checked out and run:
SHADERC_LIB_DIR=/home/nik/prj/shaderc/install/lib cargo run -v --bin triangle
Which results in this:
I've tried many things, but nothing seems to work.
Does anyone know what is going wrong?
The text was updated successfully, but these errors were encountered: