Rust 支持交叉编译,可以在 macOS 平台编译出 Linux 或者 Windows 可运行的程序,或者在 Linux 平台编译 macOS 或者 Windows 可运行的程序。 本文主要文章讲解Mac平台编译为其他平台的二进制程序。想要实现跨平台编译且可运行的程序,那么我们就需要静态链接,这样生成程序才不会因为动态链接库的原因运行失败。
cargo build--release --target x86_64-pc-windows-gnu 编译出来后在target里会有个x86_64-pc-windows-gnu目录,里面又根据--release有debug和release目录,其中xxx.exe为打包出来的Windows环境程序软件。 参考: 1.https://www.qttc.net/529-rust-cross-compile-mac-to-linux.html 2.https://www.cnblogs.com/...
$ file target/x86_64-unknown-linux-musl/debug/hello target/x86_64-unknown-linux-musl/debug/hello: ELF 64-bit LSB pieexecutable, x86-64, version 1 (SYSV), static-pie linked, with debug_info, not stripped 编译为Windows平台 mingw-w64是用来编译到Windows的工具链,使用如下命令进行安装: brew in...
想要实现Linux平台可以运行的程序,那么就需要使用musl来替代glibc,musl实现了Linux libc。 musl 在macOS上使用musl-cross,musl-cross是专门编译到Linux的工具链,下面进行安装: muslhttps://musl.libc.org/ $ brew install FiloSottile/musl-cross/musl-cross 1. 还需要创建musl-gcc: $ ln -s /usr/local/bin/x...
下面,我们就简单来启动一个小项目来讲解一下如何使用cross进行Rust的跨平台编译。 4. 项目初始化 又到了我们再熟悉不过的场景了。我们用cargo new构建一个项目 cargo new cross_compile 然后,我们将main.rs中内容替换成如下代码: use current_platform::CURRENT_PLATFORM; ...
cargo build--release --target x86_64-pc-windows-gnu 1. 2. 3. 4. 5. 6. 7. 编译出来后在target里会有个x86_64-pc-windows-gnu目录,里面又根据--release有debug和release目录,其中xxx.exe为打包出来的Windows环境程序软件。 参考: 1.https://www.qttc.net/529-rust-cross-compile-mac-to-linux.htm...
You can find there are more files from windows lib then from linux multirust lib fori686-pc-windows-gnu. I copy.from windows lib to linux multirust lib. Then it works. Perhaps multirust is not picking good source of files when it adds target? I don't know. ...
编译完成后,会自动生成target文件夹,在target/x86_64-unknown-linux-musl/release文件夹下的cross_compile_test就是最终的Linux可执行二进制文件。 0x03 文件测试 我们将文件拷贝到CentOS中测试。可以完美执行~~~ image 0x04 扩展——Windows静态编译 不知道你是否测试过下面的这个场景。在Windows上,如果把每次使用car...
Wayland 的应用更进一步,gdm 已经默认使用 wayland 了,但是 gnome-session 依然默认使用 Xorg 。以前...
These files run on Linux machines, and our goal is to cross compile them into a Windows executable. The cross compilation of your Rust code will be done via Docker. Download and install the latest version of Docker Desktop. Choose the version matching your workstation OS — and remember to...