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

Linking failures with libz and search path #7

Open
jetuk opened this issue Feb 13, 2023 · 2 comments
Open

Linking failures with libz and search path #7

jetuk opened this issue Feb 13, 2023 · 2 comments

Comments

@jetuk
Copy link
Contributor

jetuk commented Feb 13, 2023

I am having some trouble linking to highs-sys from my own crate. This is using v1.5.0 and rust v1.67.0 on Fedora 37. I have found two problems:

  1. Missing libz requirement.
   = note: /usr/bin/ld: /home/runner/work/pywr-next/pywr-next/target/debug/deps/libhighs_sys-0966d10c628bb43f.rlib(HMPSIO.cpp.o): undefined reference to symbol 'inflateEnd'
          /usr/bin/ld: /lib/x86_64-linux-gnu/libz.so.1: error adding symbols: DSO missing from command line
          collect2: error: ld returned 1 exit status

Full build log is here: https://github.com/pywr/pywr-next/actions/runs/4158414784/jobs/7193618930

I fixed this locally by adding the following to build.rs.

    println!("cargo:rustc-link-lib=dylib=z");
  1. Failing to find the static library in the local build directory. For some reason it is added to lib64 and not lib on my system. I had to change build.rs to point to lib64 locally.
    println!("cargo:rustc-link-search=native={}/lib64", dst.display());

I am not at all sure why the tests for highs-sys pass fine with no modifications to build.rs, but I need both of these changes when linking from my crate. What am I doing wrong?

@bluenote-1577
Copy link

Issue 2. also appears for me on CentOS 7 with rust v1.67.1 and highs v1.5.0 (but I didn't have issue 1 appear).

Could issue 2 be resolved by simply having both

    println!("cargo:rustc-link-search=native={}/lib64", dst.display());
    println!("cargo:rustc-link-search=native={}/lib", dst.display());

be present, to search both lib and lib64?

@Thell
Copy link
Contributor

Thell commented Apr 16, 2023

I too needed to link libz and println!("cargo:rustc-link-lib=z"); did the job.
Perhaps my simplistic solution is too simplistic and narrow for a pull request #10 but at least there's a test included that will test if it is working or not.

Edit: Just wanted to leave a note and say the this did not work on Windows by itself but works if libz-sys is added as a dep. 👍

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