I am trying out Rust with a simple hello world program and am getting a linker error. I have "rustc" and "cargo" installed also.
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 instructions on the Google Rust quick start webpage 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:/ #
Thanks for any advice.