![]() ![]() This is simply done using rustup target add x86_64-unknown-linux-gnu.īut to actually compile to the given target we also need a linker. The first step is always to install the standard library using rustup. But I will also explain how to build for the musl target. The gnu target on the other hand produces a dynamically linked binary which depends on glibc being installed on the host system.īecause glibc is often a bit faster than musl I decided to go with the gnu target. The drawback is that musl is often quite a bit slower than glibc and therefore not the optimal choice for many projects. The benefit of statically linking the C standard library is that it will run on basically any modern Linux operating system with no dependencies. The musl target produces a statically linked binary using the musl C standard library which aims to be very lightweight and simple. When choosing the right build target I had the choice between x86_64-unknown-linux-gnu and x86_64-unknown-linux-musl. Add the target flag to your build command: cargo build -release -target.Set the TARGET_CC environment variable to the linker executable during compilation.Update the cargo configuration so rustc can find the linker.Install the standard library for the target using rustup target add.Generally, these are the steps necessary to compile from one platform to another: You also have to install a linker for the platform and tell rustc where to find it.įor some platforms, other dependencies might be necessary as well, but in this article, I will concentrate on compiling from Mac to Linux. To cross-compile from one platform to another, it’s usually not enough to just install the standard library for the target using rustup. ![]() This mainly consists of my own findings and might not work for everyone. While trying to cross-compile rust from Mac to Linux I ran into a few issues, so I thought I would write a simple guide for myself and anyone else interested.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |