Rust error: linking with cc failed: exit status: 1 (with simple hello world program)

I was trying to run a small "hello world" program and received a few errors. This is one of them. I have a new Rust installation with Cargo on FreeBSD14.3.

root@user-ghostbsd:/home/user/Downloads/memory # cargo run
Compiling proc-macro2 v1.0.105
Compiling quote v1.0.43
Compiling libm v0.2.15
Compiling libc v0.2.180
Compiling serde_core v1.0.228
Compiling portable-atomic v1.13.0
Compiling serde v1.0.228
Compiling rustix v1.1.3
error: linking with cc failed: exit status: 1
|
= note: "cc" "-m64" "/tmp/rustcYZEtLK/symbols.o" "<2 object files omitted>" "-Wl,--as-needed" "-Wl,-Bstatic" "/lib/rustlib/x86_64-unknown-freebsd/lib/{libstd-,libpanic_unwind-,libobject-,libmemchr-,libaddr2line-,libgimli-,libcfg_if-,librustc_demangle-,libstd_detect-,libhashbrown-,librustc_std_workspace_alloc-,libminiz_oxide-,libadler2-,libunwind-,liblibc-,librustc_std_workspace_core-,liballoc-,libcore-,libcompiler_builtins-*}.rlib" "-Wl,-Bdynamic" "-lexecinfo" "-lpthread" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lrt" "-lutil" "-lexecinfo" "-lkvm" "-lmemstat" "-lkvm" "-lutil" "-lprocstat" "-lrt" "-ldevstat" "-L" "/tmp/rustcYZEtLK/raw-dylibs" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-o" "/home/user/Downloads/memory/target/debug/build/quote-ebcbd81c14b23f6f/build_script_build-ebcbd81c14b23f6f" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs"
= note: some arguments are omitted. use --verbose to show all linker arguments
= note: ld: error: cannot open Scrt1.o: No such file or directory
ld: error: cannot open crti.o: No such file or directory
ld: error: cannot open crtbeginS.o: No such file or directory
ld: error: unable to find library -lexecinfo
ld: error: unable to find library -lpthread
ld: error: unable to find library -lgcc_s
ld: error: unable to find library -lc
ld: error: unable to find library -lm
ld: error: unable to find library -lrt
ld: error: unable to find library -lpthread
ld: error: unable to find library -lrt
ld: error: unable to find library -lutil
ld: error: unable to find library -lexecinfo
ld: error: unable to find library -lkvm
ld: error: unable to find library -lmemstat
ld: error: unable to find library -lkvm
ld: error: unable to find library -lutil
ld: error: unable to find library -lprocstat
ld: error: unable to find library -lrt
ld: error: unable to find library -ldevstat
ld: error: too many errors emitted, stopping now (use --error-limit=0 to see all errors)
cc: error: linker command failed with exit code 1 (use -v to see invocation)

There a few more errors, but each is about the same as the one above. I am new to Rust. The only "ld" folder I found was: /compat/linux/dev/fd/152854/ld and it was empty except for three files that seemed to not have anything to do with the "unable to find library" errors. I have the GNU compiler collection, cargo, and the Rust language installed.

Any help with this is appreciated much. Thanks.
 
I typed these commands into a terminal and updated the packages.

pkg update -f
pkg upgrade

I typed this afterwards:
freebsd-version -kru

and received:

root@user-ghostbsd:/ # freebsd-version -kru
14.3-RELEASE-p7
14.3-RELEASE-p7
14.3-RELEASE-p7
root@user-ghostbsd:/ #

I followed the Google link you sent. The Google files are identical to mine. I followed the instructions and used both "cargo run" and in another terminal window "rustc" like in the directions. The error message was the same for both runs.

root@user-ghostbsd:/home/user/Documents/Rust/hello_world # cargo build
Compiling hello_world v0.1.0 (/home/user/Documents/Rust/hello_world)
error: linking with `cc` failed: exit status: 1
|
= note: "cc" "-m64" "/tmp/rustcUXAW11/symbols.o" "<7 object files omitted>" "-Wl,--as-needed" "-Wl,-Bstatic" "<sysroot>/lib/rustlib/x86_64-unknown-freebsd/lib/{libstd-*,libpanic_unwind-*,libobject-*,libmemchr-*,libaddr2line-*,libgimli-*,libcfg_if-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libminiz_oxide-*,libadler2-*,libunwind-*,liblibc-*,librustc_std_workspace_core-*,liballoc-*,libcore-*,libcompiler_builtins-*}.rlib" "-Wl,-Bdynamic" "-lexecinfo" "-lpthread" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lrt" "-lutil" "-lexecinfo" "-lkvm" "-lmemstat" "-lkvm" "-lutil" "-lprocstat" "-lrt" "-ldevstat" "-L" "/tmp/rustcUXAW11/raw-dylibs" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-o" "/home/user/Documents/Rust/hello_world/target/debug/deps/hello_world-209ce5c2dcd04bd0" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs"
= note: some arguments are omitted. use `--verbose` to show all linker arguments
= note: /usr/local/bin/x86_64-unknown-freebsd14.3-ld: cannot find Scrt1.o: No such file or directory
/usr/local/bin/x86_64-unknown-freebsd14.3-ld: cannot find crti.o: No such file or directory
/usr/local/bin/x86_64-unknown-freebsd14.3-ld: cannot find crtbeginS.o: No such file or directory
/usr/local/bin/x86_64-unknown-freebsd14.3-ld: cannot find -lexecinfo: No such file or directory
/usr/local/bin/x86_64-unknown-freebsd14.3-ld: cannot find -lpthread: No such file or directory
/usr/local/bin/x86_64-unknown-freebsd14.3-ld: cannot find -lgcc_s: No such file or directory
/usr/local/bin/x86_64-unknown-freebsd14.3-ld: cannot find -lc: No such file or directory
/usr/local/bin/x86_64-unknown-freebsd14.3-ld: cannot find -lm: No such file or directory
/usr/local/bin/x86_64-unknown-freebsd14.3-ld: cannot find -lrt: No such file or directory
/usr/local/bin/x86_64-unknown-freebsd14.3-ld: cannot find -lpthread: No such file or directory
/usr/local/bin/x86_64-unknown-freebsd14.3-ld: cannot find -lrt: No such file or directory
/usr/local/bin/x86_64-unknown-freebsd14.3-ld: cannot find -lutil: No such file or directory
/usr/local/bin/x86_64-unknown-freebsd14.3-ld: cannot find -lexecinfo: No such file or directory
/usr/local/bin/x86_64-unknown-freebsd14.3-ld: cannot find -lkvm: No such file or directory
/usr/local/bin/x86_64-unknown-freebsd14.3-ld: cannot find -lmemstat: No such file or directory
/usr/local/bin/x86_64-unknown-freebsd14.3-ld: cannot find -lkvm: No such file or directory
/usr/local/bin/x86_64-unknown-freebsd14.3-ld: cannot find -lutil: No such file or directory
/usr/local/bin/x86_64-unknown-freebsd14.3-ld: cannot find -lprocstat: No such file or directory
/usr/local/bin/x86_64-unknown-freebsd14.3-ld: cannot find -lrt: No such file or directory
/usr/local/bin/x86_64-unknown-freebsd14.3-ld: cannot find -ldevstat: No such file or directory
/usr/local/bin/x86_64-unknown-freebsd14.3-ld: cannot find crtendS.o: No such file or directory
/usr/local/bin/x86_64-unknown-freebsd14.3-ld: cannot find crtn.o: No such file or directory
cc: error: linker command failed with exit code 1 (use -v to see invocation)


error: could not compile `hello_world` (bin "hello_world") due to 1 previous error
root@user-ghostbsd:/home/user/Documents/Rust/hello_world #

I checked into that directory in the error message:

root@user-ghostbsd:/usr/local/bin # cd x86_64-unknown-freebsd14.3-ld
cd: x86_64-unknown-freebsd14.3-ld: Not a directory
root@user-ghostbsd:/usr/local/bin #

It may not mean anything, but this is my path:

root@user-ghostbsd:/ # echo $PATH
/home/user/.cargo/bin:/usr/local/gnat12/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/home/user/bin
root@user-ghostbsd:/ #

I'm still reading about this linking error and have not found anything yet. I have "GhostBSD" since it comes with a desktop. I tried for days to get a desktop on a mainstream version of FreeBSD, but the builds kept failing and I followed the manual. The Git "desktop-installer" did not work either. I'll be updating my FreeBSD version to 15 on the 16th of January when it comes available for GhostBSD. There is supposed to be a well funded FreeBSD laptop project that might make things easier to install, but it will take time for that to get completed.

Thanks for your time with this.
 
Back
Top