GhostBSD/FreeBSD error: linker cc not found

I installed rustup on GhostBSD (FreeBSD 12.1-STABLE GENERIC).

$ rustup --version
rustup 1.21.1 (7832b2ebe 2019-12-20)
$ cargo --version
cargo 1.44.0 (05d080faa 2020-05-06)
$ rustc --version
rustc 1.44.0 (49cae5576 2020-06-01)
cargo build will not complete, complains that it can't find 'cc' linker, even with a new "hello world" main.rs.
Compiling ip-sniffer v0.1.0 (/usr/home/rgeorgia/workspace/ip-sniffer)
Running `rustc --crate-name ip_sniffer --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=cb470888434ba471 -C extra-filename=-cb470888434ba471 --out-dir /usr/home/rgeorgia/workspace/ip-sniffer/target/debug/deps -C incremental=/usr/home/rgeorgia/workspace/ip-sniffer/target/debug/incremental -L dependency=/usr/home/rgeorgia/workspace/ip-sniffer/target/debug/deps`
    error: linker `cc` not found
      |
      = note: No such file or directory (os error 2)

    error: aborting due to previous error

    error: could not compile `ip-sniffer`.

    Caused by:
      process didn't exit successfully: `rustc --crate-name ip_sniffer --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=cb470888434ba471 -C extra-filename=-cb470888434ba471 --out-dir /usr/home/rgeorgia/workspace/ip-sniffer/target/debug/deps -C incremental=/usr/home/rgeorgia/workspace/ip-sniffer/target/debug/incremental -L dependency=/usr/home/rgeorgia/workspace/ip-sniffer/target/debug/deps` (exit code: 1)

If I set the RUSTFLAGS, I get the same error:

set -g -x RUSTFLAGS "-C link-args=-L/usr/local/lib"

Using config file:

cat ~/.cargo/config

[target.x86_64-unknown-freebsd]
linker = "gcc9"
rustflags = "-L/usr/local/lib"

Doing a cargo build --verbose yields a massive amount of stuff. I can post if requested.

Is there a way to use rustup on FreeBSD?

Do you have c compiler and cc symlink?

I do not. Nothing symlinked to /usr/bin/cc

ll /usr/bin | grep cc
lrwxr-xr-x   1 root  wheel    19B Jun  6 20:37 cc -> /usr/local/bin/gcc9
cargo build
   Compiling ip-sniffer v0.1.0 (/usr/home/rgeorgia/workspace/ip-sniffer)
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/usr/home/rgeorgia/.rustup/toolchains/stable-x86_64-unknown-freebsd/lib/rustlib/x86_64-unknown-freebsd/lib" "/usr/home/rgeorgia/workspace/ip-sniffer/target/debug/deps/ip_sniffer-cb470888434ba471.2czexpyycuckv5bz.rcgu.o" "/usr/home/rgeorgia/workspace/ip-sniffer/target/debug/deps/ip_sniffer-cb470888434ba471.2pnb7uj6yrq16ofn.rcgu.o" "/usr/home/rgeorgia/workspace/ip-sniffer/target/debug/deps/ip_sniffer-cb470888434ba471.35a6r4wd1antiu8d.rcgu.o" "/usr/home/rgeorgia/workspace/ip-sniffer/target/debug/deps/ip_sniffer-cb470888434ba471.41d1rhvhl8qfo1s3.rcgu.o" "/usr/home/rgeorgia/workspace/ip-sniffer/target/debug/deps/ip_sniffer-cb470888434ba471.587ox1onlesh6p1h.rcgu.o" "/usr/home/rgeorgia/workspace/ip-sniffer/target/debug/deps/ip_sniffer-cb470888434ba471.7p8u1tkksbyokh7.rcgu.o" "-o" "/usr/home/rgeorgia/workspace/ip-sniffer/target/debug/deps/ip_sniffer-cb470888434ba471" "/usr/home/rgeorgia/workspace/ip-sniffer/target/debug/deps/ip_sniffer-cb470888434ba471.3hdulyk4mfwb526s.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-nodefaultlibs" "-L" "/usr/home/rgeorgia/workspace/ip-sniffer/target/debug/deps" "-L" "/usr/home/rgeorgia/.rustup/toolchains/stable-x86_64-unknown-freebsd/lib/rustlib/x86_64-unknown-freebsd/lib" "-Wl,--start-group" "-Wl,-Bstatic" "/usr/home/rgeorgia/.rustup/toolchains/stable-x86_64-unknown-freebsd/lib/rustlib/x86_64-unknown-freebsd/lib/libstd-81ec8387470721cc.rlib" "/usr/home/rgeorgia/.rustup/toolchains/stable-x86_64-unknown-freebsd/lib/rustlib/x86_64-unknown-freebsd/lib/libpanic_unwind-28e609439e6f6127.rlib" "/usr/home/rgeorgia/.rustup/toolchains/stable-x86_64-unknown-freebsd/lib/rustlib/x86_64-unknown-freebsd/lib/libhashbrown-e9747bad5b1ecd5a.rlib" "/usr/home/rgeorgia/.rustup/toolchains/stable-x86_64-unknown-freebsd/lib/rustlib/x86_64-unknown-freebsd/lib/librustc_std_workspace_alloc-f1a00ad00cc493ce.rlib" "/usr/home/rgeorgia/.rustup/toolchains/stable-x86_64-unknown-freebsd/lib/rustlib/x86_64-unknown-freebsd/lib/libbacktrace-b1365155e3a23160.rlib" "/usr/home/rgeorgia/.rustup/toolchains/stable-x86_64-unknown-freebsd/lib/rustlib/x86_64-unknown-freebsd/lib/libbacktrace_sys-834c88227c9936aa.rlib" "/usr/home/rgeorgia/.rustup/toolchains/stable-x86_64-unknown-freebsd/lib/rustlib/x86_64-unknown-freebsd/lib/librustc_demangle-1359f55dcb2759c7.rlib" "/usr/home/rgeorgia/.rustup/toolchains/stable-x86_64-unknown-freebsd/lib/rustlib/x86_64-unknown-freebsd/lib/libunwind-1d08c192d833898e.rlib" "/usr/home/rgeorgia/.rustup/toolchains/stable-x86_64-unknown-freebsd/lib/rustlib/x86_64-unknown-freebsd/lib/libcfg_if-f6c6a2ce29b39642.rlib" "/usr/home/rgeorgia/.rustup/toolchains/stable-x86_64-unknown-freebsd/lib/rustlib/x86_64-unknown-freebsd/lib/liblibc-981598b544724287.rlib" "/usr/home/rgeorgia/.rustup/toolchains/stable-x86_64-unknown-freebsd/lib/rustlib/x86_64-unknown-freebsd/lib/liballoc-4e654ad9d11fc750.rlib" "/usr/home/rgeorgia/.rustup/toolchains/stable-x86_64-unknown-freebsd/lib/rustlib/x86_64-unknown-freebsd/lib/librustc_std_workspace_core-4d6b2ad2f735ac80.rlib" "/usr/home/rgeorgia/.rustup/toolchains/stable-x86_64-unknown-freebsd/lib/rustlib/x86_64-unknown-freebsd/lib/libcore-5aacddcf0d3ed9d9.rlib" "-Wl,--end-group" "/usr/home/rgeorgia/.rustup/toolchains/stable-x86_64-unknown-freebsd/lib/rustlib/x86_64-unknown-freebsd/lib/libcompiler_builtins-2345068ed344c5a9.rlib" "-Wl,-Bdynamic" "-lexecinfo" "-lpthread" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lutil" "-lutil"
  = note: /usr/local/bin/ld: cannot find /usr/lib/libc_nonshared.a
          /usr/local/bin/ld: cannot find /usr/lib/libssp_nonshared.a
          collect2: error: ld returned 1 exit status
          

error: aborting due to previous error

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.