Having used HiGHS in other languages, I was pleased to find a Rust interface. The issue occurred when I went to test a simple example, placed within a crate solely for that purpose. On the first attempt to build, the following error occurred (the relevant portion of the output from cargo build --verbose):
Compiling highs v1.5.0
Running `rustc --crate-name highs --edition=2021 /a-home-path/.cargo/registry/src/github.com-1ecc6299db9ec823/highs-1.5.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=104 --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C metadata=0db78eb3c15fc5a1 -C extra-filename=-0db78eb3c15fc5a1 --out-dir /some-long-path/rust-projects/math-etc/linprog/target/debug/deps -L dependency=/some-long-path/rust-projects/math-etc/linprog/target/debug/deps --extern highs_sys=/some-long-path/rust-projects/math-etc/linprog/target/debug/deps/libhighs_sys-9386df42f8196f19.rmeta --extern log=/some-long-path/rust-projects/math-etc/linprog/target/debug/deps/liblog-24b3002f70d5efb0.rmeta --cap-lints allow -C linker=/some-long-path/toolchains/bin/clang -C link-arg=-fuse-ld=lld -C linker=/some-long-path/toolchains/bin/clang -C link-arg=-fuse-ld=lld -L native=/some-long-path/rust-projects/math-etc/linprog/target/debug/build/highs-sys-45d22f72c4d7b9c6/out/lib`
error: could not find native static library `highs`, perhaps an -L flag is missing?
error: could not compile `highs-sys` due to previous error
Caused by:
process didn't exit successfully: `rustc --crate-name highs_sys --edition=2018 /a-home-path/.cargo/registry/src/github.com-1ecc6299db9ec823/highs-sys-1.5.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=104 --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C metadata=9386df42f8196f19 -C extra-filename=-9386df42f8196f19 --out-dir /some-long-path/rust-projects/math-etc/linprog/target/debug/deps -L dependency=/some-long-path/rust-projects/math-etc/linprog/target/debug/deps --cap-lints allow -C linker=/some-long-path/toolchains/bin/clang -C link-arg=-fuse-ld=lld -C linker=/some-long-path/toolchains/bin/clang -C link-arg=-fuse-ld=lld -L native=/some-long-path/rust-projects/math-etc/linprog/target/debug/build/highs-sys-45d22f72c4d7b9c6/out/lib -l static=highs -l dylib=stdc++ -l dylib=gomp` (exit status: 1)
warning: build failed, waiting for other jobs to finish...
The solution was fairly simple: change to println!("cargo:rustc-link-search=native={}/lib64", dst.display()); in build.rs, as /lib did not exist. As always, this could just be an issue with my toolchain.
Version:
high-sys v1.5.0
rust v1.69.0
Toolchain:
clang/clang++ 17.0, with CC and CXX environment variables set to /some-long-path/toolchains/bin/clang and /some-long-path/toolchains/bin/clang++, respectively
lld is my usual linker, but in the spirit of full disclosure: in .cargo/.config.toml[build] rustflags = ["-C", "linker=/some-long-path/toolchains/bin/clang", "-C", "link-arg=-fuse-ld=lld"]
Having used HiGHS in other languages, I was pleased to find a Rust interface. The issue occurred when I went to test a simple example, placed within a crate solely for that purpose. On the first attempt to build, the following error occurred (the relevant portion of the output from
cargo build --verbose
):The solution was fairly simple: change to
println!("cargo:rustc-link-search=native={}/lib64", dst.display());
inbuild.rs
, as/lib
did not exist. As always, this could just be an issue with my toolchain.Version:
Toolchain:
CC
andCXX
environment variables set to/some-long-path/toolchains/bin/clang
and/some-long-path/toolchains/bin/clang++
, respectivelylld
is my usual linker, but in the spirit of full disclosure: in.cargo/.config.toml
[build] rustflags = ["-C", "linker=/some-long-path/toolchains/bin/clang", "-C", "link-arg=-fuse-ld=lld"]