Linker 'cc' not found (FreeBSD 12.3)

tl;dr I am unable to run cargo install due to linker error "error: linker 'cc' not found"

# cargo install --locked super_speedy_syslog_searcher
   ...
   Compiling libc v0.2.139
   Compiling version_check v0.9.4
   Compiling cfg-if v1.0.0
   Compiling proc-macro2 v1.0.49
   Compiling unicode-ident v1.0.6
   Compiling quote v1.0.23
error: linker `cc` not found
  |
  = note: No such file or directory (os error 2)

error: could not compile `libc` due to previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `proc-macro2` due to previous error
error: could not compile `quote` due to previous error
error: failed to compile `super_speedy_syslog_searcher v0.2.47`, intermediate artifacts can be found at `/tmp/cargo-installrYoBnE`

This rust installation uses the FreeBSD pkg package manager on FreeBSD 12.3, and rust 1.66.0.

# cargo --version
cargo 1.66.0
# uname -a
FreeBSD hostname 12.3-STABLE FreeBSD 12.3-STABLE RELENG_2_6_0-n226742-1285d6d205f pfSense  amd64


This post continues this older post that I cannot reply (it's been closed) https://users.rust-lang.org/t/ghostbsd-freebsd-error-linker-cc-not-found/

A fix is a simple symbolic link

# cd /usr/local/bin
# ln -vs gcc cc
cc -> gcc

The cargo install command succeeds.

Taken from this idea posted by ronverbs. In that case, @ronverbs linked a full path from a different directory /usr/bin.

ll /usr/bin | grep cc
lrwxr-xr-x   1 root  wheel    19B Jun  6 20:37 cc -> /usr/local/bin/gcc9

whereas my symbolic link was a relative path in the same directory /usr/bin/local

# ls -las /usr/local/bin/ | grep cc
    1 lrwxr-xr-x   1 root  wheel         3 Jan 10 18:29 cc -> gcc
    1 lrwxr-xr-x   1 root  wheel         5 Dec 12 00:20 gcc -> gcc12
  517 -rwxr-xr-x   3 root  wheel    937064 Dec  3 10:55 gcc12
...

It's possible this was the crucial difference.

1 Like

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.