英文:
Is there a problem with my trust Cross compiler
问题
I first encountered Trust today and encountered this error when I wrote the first 'hello world' based on official documentation
root@VM-4-14-ubuntu:~/homemadeOS/OSfoundation/rustExercise/demo# rustc src/main.rs
error: linking with `cc` failed: exit status: 1
|
= note: LC_ALL="C" PATH="/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/ubuntu/.cargo/bin:/home/ubuntu/nvim-linux64/bin:/home/ubuntu/cross-compiler//bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin" VSLANG="1033" "cc" "-m64" "/tmp/rustcVEWi2j/symbols.o" "main.main.bd587cf2a5a1bf91-cgu.0.rcgu.o" "main.main.bd587cf2a5a1bf91-cgu.1.rcgu.o" "main.main.bd587cf2a5a1bf91-cgu.2.rcgu.o" "main.main.bd587cf2a5a1bf91-cgu.3.rcgu.o" "main.main.bd587cf2a5a1bf91-cgu.4.rcgu.o" "main.main.bd587cf2a5a1bf91-cgu.5.rcgu.o" "main.4x73ygqb52ry76yh.rcgu.o" "-Wl,--as-needed" "-L" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-0d91c78a7710ed2e.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-9bfeb974ba4dc4e7.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-7dd2d47ddb5fff81.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-18d5ce8e8a320b85.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-69d2770595dc6161.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-b156a020cc470e38.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-84091f15e468b1ee.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-fbde6acb28b510ca.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-e9de5d8ee4e7a3dd.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-9023252e4f119830.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-fcbb01769e88af40.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-f69e84994e245fea.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-27b55c02caca49ea.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-579b26075cbe9eca.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-54c30397d4b33d3b.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-65fb576691133eee.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-3fff6412017c0b89.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-fd3918c72578db43.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-2a597573799b576f.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "main" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs"
= note: /home/ubuntu/cross-compiler/lib/gcc/i686-elf/11.2.0/../../../../i686-elf/bin/ld: cannot find crt0.o: No such file or directory /tmp/rustcVEWi2j/symbols.o: file not recognized: file format not recognized
collect2: error: ld returned 1 exit status
error: aborting due to previous error
this is my project Directory
(I created the project directory using the method of cargo new demo bin
)
Cargo.lock Cargo.toml src/ target/
After I execute some commands,
英文:
I first encountered Trust today and encountered this error when I wrote the first 'hello world' based on official documentation
root@VM-4-14-ubuntu:~/homemadeOS/OSfoundation/rustExercise/demo# rustc src/main.rs
error: linking with `cc` failed: exit status: 1
|
= note: LC_ALL="C" PATH="/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/ubuntu/.cargo/bin:/home/ubuntu/nvim-linux64/bin:/home/ubuntu/cross-compiler//bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin" VSLANG="1033" "cc" "-m64" "/tmp/rustcVEWi2j/symbols.o" "main.main.bd587cf2a5a1bf91-cgu.0.rcgu.o" "main.main.bd587cf2a5a1bf91-cgu.1.rcgu.o" "main.main.bd587cf2a5a1bf91-cgu.2.rcgu.o" "main.main.bd587cf2a5a1bf91-cgu.3.rcgu.o" "main.main.bd587cf2a5a1bf91-cgu.4.rcgu.o" "main.main.bd587cf2a5a1bf91-cgu.5.rcgu.o" "main.4x73ygqb52ry76yh.rcgu.o" "-Wl,--as-needed" "-L" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-0d91c78a7710ed2e.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-9bfeb974ba4dc4e7.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-7dd2d47ddb5fff81.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-18d5ce8e8a320b85.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-69d2770595dc6161.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-b156a020cc470e38.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-84091f15e468b1ee.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-fbde6acb28b510ca.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-e9de5d8ee4e7a3dd.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-9023252e4f119830.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-fcbb01769e88af40.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-f69e84994e245fea.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-27b55c02caca49ea.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-579b26075cbe9eca.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-54c30397d4b33d3b.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-65fb576691133eee.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-3fff6412017c0b89.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-fd3918c72578db43.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-2a597573799b576f.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "main" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs"
= note: /home/ubuntu/cross-compiler/lib/gcc/i686-elf/11.2.0/../../../../i686-elf/bin/ld: cannot find crt0.o: No such file or directory /tmp/rustcVEWi2j/symbols.o: file not recognized: file format not recognized
collect2: error: ld returned 1 exit status
error: aborting due to previous error
this is my project Directory
(I created the project directory using the method of cargo new demo bin
)
Cargo.lock Cargo.toml src/ target/
After I execute some commands, I will generate some unknown files
root@VM-4-14-ubuntu:~/homemadeOS/OSfoundation/rustExercise/demo# ls
Cargo.lock main.main.bd587cf2a5a1bf91-cgu.0.rcgu.o main.main.bd587cf2a5a1bf91-cgu.3.rcgu.o src
Cargo.toml main.main.bd587cf2a5a1bf91-cgu.1.rcgu.o main.main.bd587cf2a5a1bf91-cgu.4.rcgu.o target
main.4x73ygqb52ry76yh.rcgu.o main.main.bd587cf2a5a1bf91-cgu.2.rcgu.o main.main.bd587cf2a5a1bf91-cgu.5.rcgu.o
I guess this may have something to do with reporting an error
about the "/tmp/rustcVEWi2j/symbols.o"
I tried using the file /tmp/rustcVEWi2j/symbols.o
command and this occurred
root@VM-4-14-ubuntu:~/homemadeOS/OSfoundation/rustExercise/demo# file /tmp/rustcVEWi2j/symbols.o
/tmp/rustcVEWi2j/symbols.o: cannot open `/tmp/rustcVEWi2j/symbols.o' (No such file or directory)
So I want to know whether this error is due to my wrong Cross compiler
答案1
得分: 1
也许你应该使用以下命令编译演示项目:
cargo build
这将在后台调用rustc
并为您进行链接。
要执行,您有两种选择:
cargo run
或者
在编译后生成的target
文件夹中查找二进制文件并执行它。
英文:
Maybe you should be compiling the demo project with
cargo build
This will call rustc
in the background and do the linking for you.
for execute you have two alternatives:
cargo run
or
search the binary in the target
folder (that will be generated after compiling) and execute it.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论