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

from-source gives: libscip.so.9.0: cannot open shared object file: No such file or directory #136

Open
jacobsvante opened this issue Mar 30, 2024 · 6 comments

Comments

@jacobsvante
Copy link

Using the new feature from-source, available since 0.3.3, I'm unable to run the built binary. Here's my MRE:

Dockerfile:

FROM rust:1.77
WORKDIR /work
RUN apt-get update && apt-get install -y cmake clang
RUN wget https://github.com/scipopt/russcip/archive/refs/tags/v0.3.3.tar.gz \
    && tar -xzvf v0.3.3.tar.gz \
    && mv russcip-0.3.3 /russcip
WORKDIR /russcip
RUN cargo build --release -F from-source --example create_and_solve
CMD ["./target/release/examples/create_and_solve"]

Build:

docker build .

Run / error:

docker run -it --rm russcip-test:latest
./target/release/examples/create_and_solve: error while loading shared libraries: libscip.so.9.0: cannot open shared object file: No such file or directory
@mwien
Copy link

mwien commented Mar 30, 2024

Same here. With cargo run it works, similar to the bundled feature.

Seems like the same difficulties with dynamic linking. Is it possible to add static linking now with from-source-building?

@mmghannam
Copy link
Member

Sorry guys for the false hope 😄 but at least now the build process can be controlled from rust, so it's a small step in the right direction. Unfortunately, only setting SHARED=false is not enough, I will be iterating on it in this PR scipopt/scip-sys#15

@jacobsvante
Copy link
Author

No worries, I'm just happy to see you working on it 😀

@mmghannam
Copy link
Member

mmghannam commented Mar 31, 2024

I think I found a nice solution that doesn't requires much work. I updated scip-sys (v0.1.12, and a corresponding russcip version 0.3.4 to use it) to also say where it found libscip. It sets the environment variable DEP_SCIP_LIBDIR. You could use that information to set the rpath of the binary you're building by adding something like this to your build script

fn main() {
    let libscip_dir = std::env::var("DEP_SCIP_LIBDIR").unwrap();
    println!("cargo:rustc-link-arg=-Wl,-rpath,{}", libscip_dir);
}

I think you might also need to add scip-sys to the dependencies of your crate not just russcip.
It's not probably the nicest solution since it requires a bit of effort from the downstream user of scip-sys but should do the job. @jacobsvante @mwien What do you think?

@mwien
Copy link

mwien commented Mar 31, 2024

I think for the bundled feature with pre-built binary that cannot be statically linked it is likely the only way and a nice-to-have option 👍

Will test it out in the coming days.

I'm still gonna look into static linking because I probably need it for a project. Gonna write if I can make it work, should be doable in principle 🤔

Thanks for your work ❤️

@jacobsvante
Copy link
Author

Haven't had the chance to try yet but will soon.
Have you tried building and linking scip statically?

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