I have a simple file main.rs, with the print Hello, World from Rust!. Under my system, Linux, everything compiles without any problems, both through rustc and through cargo. But when I want to make a build for another system, for example macOS, I get an error.
What am I doing:
rustup target add x86_64-apple-darwin
rustc ./main.rs --target=x86_64-apple-darwin
Error:
error: linking with `cc` failed: exit status: 1
|
= note: LC_ALL="C" PATH="/home/daniilskli/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/daniilskli/.config/composer/vendor/bin:/home/daniilskli/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/android-sdk/tools:/opt/android-sdk/tools/bin:/opt/cuda/bin:/opt/cuda/nsight_compute:/opt/cuda/nsight_systems/bin:/home/daniilskli/.dotnet/tools:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/lib/rustup/bin" VSLANG="1033" ZERO_AR_DATE="1" "cc" "-arch" "x86_64" "-m64" "/tmp/rustctIgaJB/symbols.o" "main.main.3f728549c24fce79-cgu.0.rcgu.o" "main.4zckhff98u3ljprx.rcgu.o" "-L" "/home/daniilskli/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib" "/home/daniilskli/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/libstd-6472438448c6c4bd.rlib" "/home/daniilskli/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-3600ed8016f8face.rlib" "/home/daniilskli/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/libobject-ea51991ef4a3658d.rlib" "/home/daniilskli/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/libmemchr-96b3ff65689c3fce.rlib" "/home/daniilskli/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/libaddr2line-07fa1dec1d2bd3bb.rlib" "/home/daniilskli/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/libgimli-175fd87b93400a41.rlib" "/home/daniilskli/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/librustc_demangle-3b326864ccc9e9e8.rlib" "/home/daniilskli/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/libstd_detect-39dcdc3dac7bf511.rlib" "/home/daniilskli/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/libhashbrown-84429b66c29d7ef9.rlib" "/home/daniilskli/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_alloc-26b6ba85d2896aa6.rlib" "/home/daniilskli/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/libminiz_oxide-3efa691a08d42571.rlib" "/home/daniilskli/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/libadler-81d639bf7b0fb091.rlib" "/home/daniilskli/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/libunwind-f27a894b1cbe21a7.rlib" "/home/daniilskli/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/libcfg_if-1b1ed482c4b1447a.rlib" "/home/daniilskli/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/liblibc-4e263b0a0b4d1d51.rlib" "/home/daniilskli/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/liballoc-6938fc20e09e5c3a.rlib" "/home/daniilskli/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_core-f588925d2f9025bc.rlib" "/home/daniilskli/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/libcore-4b6dec082eeb7c38.rlib" "/home/daniilskli/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-950dfa4358313a7f.rlib" "-lSystem" "-lc" "-lm" "-L" "/home/daniilskli/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-apple-darwin/lib" "-o" "main" "-Wl,-dead_strip" "-nodefaultlibs"
= note: cc: error: unrecognized command-line option '-arch'
error: aborting due to previous error
x86_64-apple-darwin--targetflag that explicitly names clang as the compiler to use, too.