Skip to content
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 /usr/lib/libshaderc_shared.so #107

Open
Rua opened this issue Apr 27, 2021 · 2 comments
Open

Can't find /usr/lib/libshaderc_shared.so #107

Rua opened this issue Apr 27, 2021 · 2 comments

Comments

@Rua
Copy link

Rua commented Apr 27, 2021

I downloaded the pre-built shaderc library package for Linux, and unpacked it in /usr/lib. This is one of the locations where shaderc-rs will search for libraries according to the readme, and /usr/lib/libshaderc_shared.so is right there along with all the other shaderc libraries. Yet for some reason it fails to find the library, and proceeds to build from source (which fails because I uninstalled cmake). How come it's not finding the library? Is the documentation incorrect?

@antiagainst
Copy link
Collaborator

Hi, note that /usr/lib/ is just one example given for Linux system library paths: "On Linux, system library paths like ..". There is an implicit ordering in the library path:

search_dir = if Path::new(&debian_triple_path).exists() {
// Debian, Ubuntu and their derivatives.
Some(debian_triple_path)
} else if env::var("CARGO_CFG_TARGET_ARCH").unwrap() == "x86_64"
&& Path::new("/usr/lib64/").exists()
{
// Other distributions running on x86_64 usually use this path.
Some("/usr/lib64/".to_owned())
} else {
// Other distributions, not x86_64.
Some("/usr/lib/".to_owned())
};

And /usr/lib/ is the last one of it. I think the problem is that only directory existence was checked there; not the library. So as long as you have other directories recognized, they will be picked by the script.

This is all very tricky and ad-hoc. I think the above part should be rewritten to just use some more standardized way to probe system shared libraries.

Hopefully this clarifies.

@nbraud
Copy link

nbraud commented Jan 15, 2025

This is all very tricky and ad-hoc. I think the above part should be rewritten to just use some more standardized way to probe system shared libraries.

Yes, using pkg-config would be the standard way to solve the problem on (AFAIK) all opensource distros, be it Linux, *BSD, etc.

As it stands, this prevents using prebuilt versions of shaderc on NixOS (or any dev environment managed with nix) as they would be found under /nix/store/{hash}-shaderc-{version}-{dev, lib}/: pkg-config would find them through its environment variables, which are automatically set by a nix setup-hook for pkg-config.

PS: I was able to work around that, by setting SHADERC_LIB_DIR = lib.makeLibraryPath [ pkgs.shaderc ];. It would still make sense to use pkg-config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants