ykrist / rust-grb

Rust library bindings to the Gurobi optimiser.
MIT License
19 stars 8 forks source link

Help with Gurobi on Rust #2

Closed zhli12 closed 3 years ago

zhli12 commented 3 years ago

Hi,

I am using MacOS and I have set GUROBI_HOME to Gurobi's path. However, when running it on Rust, I received an error saying

" linking with cc failed: exit code: 1 "

with a note starting with " note: "cc" "-m64" "-arch" "x86_64" "-L" ".

After some researching online I'm still unable to pinpoint or fix the problem, so I'd really appreciate any help with it.

ykrist commented 3 years ago

Weird, I would have expected the build script to panic if it couldn't find Gurobi. I have a couple of questions:

  1. Could you provide the full error message?
  2. Where are you setting the GUROBI_HOME, and to what?
  3. Are you using the Conda packaged Gurobi or the standalone library from the Gurobi website? Which version of Gurobi are you trying to link to?
  4. When you compile with cargo clean && cargo build -v, what are the rustc invocations for grb and grb-sys2? There should be output lines like:
    Running `rustc --crate-name grb_sys2  ...
    Running `rustc --crate-name grb  ...
zhli12 commented 3 years ago

Thanks for your reply!

  1. I have attached the full error message below, which is a bit long.
  2. I set GUROBI_HOME in the file .bash_profile. The codes I used are export GRB_LICENSE_FILE="/Users/zhli12/gurobi.lic" export GUROBI_HOME="/Library/gurobi912/mac64"
  3. I downloaded Gurobi from its official website and used the line gurobi = "0.3.4" in the toml file
  4. When I used cargo run --verbose, there was one line showing Runningrustc --crate-name gurobi_demo`. I'm not sure this is what you are referring to, though where "gurobi_demo" happens to be the folder namae that contains the rs file.

error: linking withccfailed: exit code: 1 | = note: "cc" "-m64" "-arch" "x86_64" "-L" "/Users/zhli12/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/zhli12/Desktop/gurobi_demo-main/target/debug/deps/gurobi_demo.gurobi_demo.4izfv2id-cgu.0.rcgu.o" "/Users/zhli12/Desktop/gurobi_demo-main/target/debug/deps/gurobi_demo.gurobi_demo.4izfv2id-cgu.1.rcgu.o" "/Users/zhli12/Desktop/gurobi_demo-main/target/debug/deps/gurobi_demo.gurobi_demo.4izfv2id-cgu.10.rcgu.o" "/Users/zhli12/Desktop/gurobi_demo-main/target/debug/deps/gurobi_demo.gurobi_demo.4izfv2id-cgu.11.rcgu.o" "/Users/zhli12/Desktop/gurobi_demo-main/target/debug/deps/gurobi_demo.gurobi_demo.4izfv2id-cgu.12.rcgu.o" "/Users/zhli12/Desktop/gurobi_demo-main/target/debug/deps/gurobi_demo.gurobi_demo.4izfv2id-cgu.13.rcgu.o" "/Users/zhli12/Desktop/gurobi_demo-main/target/debug/deps/gurobi_demo.gurobi_demo.4izfv2id-cgu.14.rcgu.o" "/Users/zhli12/Desktop/gurobi_demo-main/target/debug/deps/gurobi_demo.gurobi_demo.4izfv2id-cgu.15.rcgu.o" "/Users/zhli12/Desktop/gurobi_demo-main/target/debug/deps/gurobi_demo.gurobi_demo.4izfv2id-cgu.2.rcgu.o" "/Users/zhli12/Desktop/gurobi_demo-main/target/debug/deps/gurobi_demo.gurobi_demo.4izfv2id-cgu.3.rcgu.o" "/Users/zhli12/Desktop/gurobi_demo-main/target/debug/deps/gurobi_demo.gurobi_demo.4izfv2id-cgu.4.rcgu.o" "/Users/zhli12/Desktop/gurobi_demo-main/target/debug/deps/gurobi_demo.gurobi_demo.4izfv2id-cgu.5.rcgu.o" "/Users/zhli12/Desktop/gurobi_demo-main/target/debug/deps/gurobi_demo.gurobi_demo.4izfv2id-cgu.6.rcgu.o" "/Users/zhli12/Desktop/gurobi_demo-main/target/debug/deps/gurobi_demo.gurobi_demo.4izfv2id-cgu.7.rcgu.o" "/Users/zhli12/Desktop/gurobi_demo-main/target/debug/deps/gurobi_demo.gurobi_demo.4izfv2id-cgu.8.rcgu.o" "/Users/zhli12/Desktop/gurobi_demo-main/target/debug/deps/gurobi_demo.gurobi_demo.4izfv2id-cgu.9.rcgu.o" "-o" "/Users/zhli12/Desktop/gurobi_demo-main/target/debug/deps/gurobi_demo" "/Users/zhli12/Desktop/gurobi_demo-main/target/debug/deps/gurobi_demo.ld2itfaztnvkbmt.rcgu.o" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/Users/zhli12/Desktop/gurobi_demo-main/target/debug/deps" "-L" "/Users/zhli12/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/zhli12/Desktop/gurobi_demo-main/target/debug/deps/libgurobi-b899937133421dfd.rlib" "/Users/zhli12/Desktop/gurobi_demo-main/target/debug/deps/libitertools-74607c886604da7d.rlib" "/Users/zhli12/Desktop/gurobi_demo-main/target/debug/deps/libgurobi_sys-86dcb0d310a1deaa.rlib" "/Users/zhli12/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd-9225b8e469c32698.rlib" "/Users/zhli12/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-2fe2b8cd4fa63c34.rlib" "/Users/zhli12/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libobject-80083cf4ee7ee3ff.rlib" "/Users/zhli12/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libaddr2line-ddf3832e718029e6.rlib" "/Users/zhli12/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libgimli-ba92c986e8ef2ca8.rlib" "/Users/zhli12/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_demangle-acd0bd456d8da820.rlib" "/Users/zhli12/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libhashbrown-55608c4156e4ecbb.rlib" "/Users/zhli12/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_alloc-4be618026614fdc7.rlib" "/Users/zhli12/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunwind-fee25922260aa100.rlib" "/Users/zhli12/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcfg_if-38ba3c5cc408e14d.rlib" "/Users/zhli12/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liblibc-899852a009fbe35f.rlib" "/Users/zhli12/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc-5687564a0ccea916.rlib" "/Users/zhli12/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_core-9ed2c58b16cff4ee.rlib" "/Users/zhli12/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcore-244bf5611f93ff45.rlib" "/Users/zhli12/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-70df686e6b4ebf5b.rlib" "-lSystem" "-lresolv" "-lc" "-lm" "-liconv"

ykrist commented 3 years ago

It looks like you are using the gurobi crate, not the grb crate (this crate). I forked the gurobi crate because it had issues and didn't seem to be maintained. If you want to try compiling with this crate, change the gurobi = 0.3.4 line in your Cargo.toml to grb = ^1.0.4.

The version of the Gurobi solver (most recent is 9.1) won't be in Cargo.toml, but will be in the output of gurobi_cl --version.

zhli12 commented 3 years ago

Thank you! I solved the problem by resetting the environmental variable