4

I'm forking this project from github: https://github.com/noshu/rustimization. I didn't make a single change but when I try to build it I get this error :

>     error: linking with `cc` failed: exit status: 1
>       = note: "cc" "-m64" "-arch" "x86_64" "/var/folders/9p/vn291mlj18g1s13y49tl7r780000gn/T/rustcdxNviS/symbols.o"
> "/Users/.../Rust_projects/rustimization/target/debug/deps/rustimization-3af854d2948fc043.1elk7eapwf6th3m4.rcgu.o"
> "/Users/.../Rust_projects/rustimization/target/debug/deps/rustimization-3af854d2948fc043.3ja3qdfz07zdy10g.rcgu.o"
> "/Users/.../Rust_projects/rustimization/target/debug/deps/rustimization-3af854d2948fc043.3wrnm2croi9nx3su.rcgu.o"
> "/Users/.../Rust_projects/rustimization/target/debug/deps/rustimization-3af854d2948fc043.4941s2k698xjahpq.rcgu.o"
> "/Users/.../Rust_projects/rustimization/target/debug/deps/rustimization-3af854d2948fc043.4dueq9qi17an9kqf.rcgu.o"
> "/Users/.../Rust_projects/rustimization/target/debug/deps/rustimization-3af854d2948fc043.4i2dq61vnyqmm4hp.rcgu.o"
> "/Users/.../Rust_projects/rustimization/target/debug/deps/rustimization-3af854d2948fc043.55wqt8z3oo73cqfs.rcgu.o"
> "/Users/.../Rust_projects/rustimization/target/debug/deps/rustimization-3af854d2948fc043.2nejxb5chza08iku.rcgu.o"
> "-L" "/Users/.../Rust_projects/rustimization/target/debug/deps" "-L"
> "/Users/.../Rust_projects/rustimization/target/debug/build/cg-sys-2e4601b1e32b5b5a/out"
> "-L"
> "/Users/.../Rust_projects/rustimization/target/debug/build/lbfgsb-sys-05c66ed3722a688a/out"
> "-L"
> "/Users/.../.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib"
> "/Users/.../.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libtest-b8ae997aa0cbfbe0.rlib"
> "/Users/.../.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libgetopts-07cf3334e5fa8a10.rlib"
> "/Users/.../.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunicode_width-d51772ee7a6845b0.rlib"
> "/Users/.../.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_std-7cb5b1914c544a60.rlib" "/Users/.../Rust_projects/rustimization/target/debug/deps/libcg_sys-7df527904c8ead66.rlib"
> "/Users/.../Rust_projects/rustimization/target/debug/deps/liblbfgsb_sys-5fa6b26a122e418c.rlib"
> "/Users/.../Rust_projects/rustimization/target/debug/deps/liblibc-5e495cc591277c08.rlib"
> "/Users/.../.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd-0f7ee384278ce82b.rlib"
> "/Users/.../.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-6023318e4257fdb3.rlib"
> "/Users/.../.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libobject-50ed95d28fda9497.rlib"
> "/Users/.../.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libmemchr-114781e2905bc242.rlib"
> "/Users/.../.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libaddr2line-841a5df74cbbcf8e.rlib"
> "/Users/.../.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libgimli-9b35810dd2e8e276.rlib"
> "/Users/.../.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_demangle-d44decaafa04c51d.rlib"
> "/Users/.../.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd_detect-aa335e35e4a7724c.rlib"
> "/Users/.../.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libhashbrown-7ac72202be300078.rlib"
> "/Users/.../.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libminiz_oxide-2930c6f21f36f92f.rlib"
> "/Users/.../.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libadler-654445a53da668f3.rlib"
> "/Users/.../.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_alloc-ce034a3eed8d4113.rlib"
> "/Users/.../.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunwind-51412ab8efb0f481.rlib"
> "/Users/.../.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcfg_if-1c20aac4d9e33893.rlib"
> "/Users/.../.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liblibc-5559092a2ede5191.rlib"
> "/Users/.../.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc-05250b6a4768a099.rlib"
> "/Users/.../.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_core-10f98b32877a2067.rlib"
> "/Users/.../.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcore-56d27115b82c9961.rlib"
> "/Users/.../.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-8b28a0a374c38504.rlib"
> "-lcgfam" "-lgfortran" "-llbfgs" "-lgfortran" "-liconv" "-lSystem"
> "-lresolv" "-lc" "-lm" "-liconv" "-L"
> "/Users/.../.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib"
> "-o"
> "/Users/.../Rust_projects/rustimization/target/debug/deps/rustimization-3af854d2948fc043"
> "-Wl,-dead_strip" "-nodefaultlibs" "-undefined" "dynamic_lookup"
> "-undefined" "dynamic_lookup"

>  = note: ld: library not found for -lgfortran
>           clang: error: linker command failed with exit code 1 (use -v to see invocation)

This is what I get from a rustc --version --verbose

rustc 1.64.0 (a55dd71d5 2022-09-19)
binary: rustc
commit-hash: a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52
commit-date: 2022-09-19
host: x86_64-apple-darwin
release: 1.64.0
LLVM version: 14.0.6

From various forums I already tried to:

  • install gcc
  • reset xcode-select
  • set up config.toml in a .cargo folder with the following
rustflags = [
    "-C", "link-arg=-undefined",
    "-C", "link-arg=dynamic_lookup",
]

6
  • Please add the full error message. You probably need to install the development version of some library, but we can't know which one without the full error. Commented Oct 13, 2022 at 7:11
  • @Jmb this is the full error message I got with a verbose build. I edited it to make it more readable though Commented Oct 13, 2022 at 8:18
  • Are you sure there are no other "note:…" lines? Otherwise, do you have the devel versions of libcgfam and liblbfgs? Also the other libraries (i.e. -l… options), but those two are non-standard, so most likely to be missing. Commented Oct 13, 2022 at 8:38
  • @Jmb my bad I missed a note line indeed. Just added it. It's about gfortran library. I don't understand why it doesn't find it. I installed the last version of gfortran for x86 macos Monterrey (my current os) and also installed gcc with homebrew, which is supposed to include gfortran too Commented Oct 13, 2022 at 8:50
  • gfortran is part of gcc, but you're linking with clang (which AIUI is the default on MacOS). Maybe linking with gcc instead would fix your issue (not being a MacOS user myself I can't tell you how to do that). Commented Oct 14, 2022 at 9:11

1 Answer 1

1

You should install xcode-select:

xcode-select --install
Sign up to request clarification or add additional context in comments.

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.