我对组装非常新.我昨天才拿起它,我看了很多例子,但仍然无法弄清楚如何写入控制台.当我似乎以自己的方式复制它时,我总是会遇到错误.
我用 C、Go 和 Rust 编写了简单的代码。
foo.c
#include <stdio.h>
int main()
{
printf("hello\n");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
foo.go
#include <stdio.h>
int main()
{
printf("hello\n");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
foo.rs
package main
import "fmt"
func main() {
fmt.Println("hello");
}
Run Code Online (Sandbox Code Playgroud)
然后我把它们全部建造起来。
fn main() {
println!("hello");
}
Run Code Online (Sandbox Code Playgroud)
他们运行良好。
$ gcc -static -o cfoo foo.c
$ go build -o gofoo foo.go
$ rustc -o rustfoo foo.rs
Run Code Online (Sandbox Code Playgroud)
Rust 可执行文件的二进制文件与其他两个相比太小,因此我怀疑它不是静态可执行文件。
$ ./cfoo; ./gofoo; ./rustfoo
hello
hello
hello
Run Code Online (Sandbox Code Playgroud)
我确认 Rust 不会生成静态可执行文件。
$ ls -l cfoo gofoo rustfoo
-rwxr-xr-x 1 lone …Run Code Online (Sandbox Code Playgroud) 我对 Rust 完全陌生。我在 Windows 10 机器上安装了 Rust。创建了一个简单的 helloworld 程序,如下所示:
fn main() {
print!("Hello world!");
}
Run Code Online (Sandbox Code Playgroud)
并用rustc rust.rs. 之后生成了两个文件:
admin@myserver MINGW64 ~/Documents/rust_test
$ ls -latrh
total 1.6M
drwxr-xr-x 1 admin 197121 0 Sep 2 03:28 ..
-rw-r--r-- 1 admin 197121 45 Sep 4 00:26 rust.rs
-rwxr-xr-x 1 admin 197121 146K Sep 4 00:26 rust.exe
-rw-r--r-- 1 admin 197121 1.5M Sep 4 00:26 rust.pdb
drwxr-xr-x 1 admin 197121 0 Sep 4 00:26 .
Run Code Online (Sandbox Code Playgroud)
我可以成功运行rust.exe并获得正确的结果。但是,当我复制rust.exe到另一个新创建的 Windows 2016 …
我尝试使用小型 Rust 应用程序创建 Docker 映像。我想在 Raspberry Pi 4b 上运行的 Kubernetes 集群上运行它。所以图像一定是linux/arm64/v8。
我在 macOS 上使用以下命令创建图像:
$ docker build --platform linux/arm64/v8 -t dasralph/ping:arm64_1.0.4 .
Run Code Online (Sandbox Code Playgroud)
但是当我在 Raspberry Pi 上运行它时,找不到执行程序:
$ sudo docker run dasralph/ping:arm64_1.0.4
Unable to find image 'dasralph/ping:arm64_1.0.4' locally
arm64_1.0.4: Pulling from dasralph/ping
4f4fb700ef54: Pull complete
38f252ce47e1: Pull complete
Digest: sha256:4fbda499e0552bf08bf230db56906d185bd340655c0cc741ad10ee0ea642c626
Status: Downloaded newer image for dasralph/ping:arm64_1.0.4
exec /ping: no such file or directory
Run Code Online (Sandbox Code Playgroud)
这是我的 Docker 文件:
# STAGE 1 is to build the binary
# Use rust-based image for …Run Code Online (Sandbox Code Playgroud) rust ×3
arm64 ×1
assembly ×1
compilation ×1
docker ×1
dockerfile ×1
fasm ×1
libc ×1
linux ×1
requirements ×1
runtime ×1