Git Product home page Git Product logo

Comments (7)

mzji avatar mzji commented on May 18, 2024 5

@Emilgardis If what I said made you feeling offensive, please accept my apologize here.

Maybe I didn't express well what I mean. Let me try to explain it in another way:
If a user known there is a thing called "cross-compiling", and known that it will let him/her compile a binary on one platform which will finally run on another platform, but known nothing about the whole process, what tool is needed, and what result could be got, then when they read this document, they feel depressed.

Basically here I think we could add some detailed tutorial for the user, for example:

If you want to cross-compile your rust program from Win32 to Win64, or vise versa, then do the following steps:

  1. ...
  2. ...
  3. ...
    After these steps, usually you will get an executable which runs on Win32/Win64 platforms! However, some other points might need be aware:
  4. ...
  5. ...
  6. ...

I think this is helpful for newbies (like me).

from rust-cross.

Emilgardis avatar Emilgardis commented on May 18, 2024

Cross compiling for i686-pc-windows-msvc from x86_64-pc-windows-msvc should be done just as any other cross compilation.

Assuming rustup is installed (highly recommended)

rustup target add i686-pc-windows-msvc
cargo build --target=i686-pc-windows-msvc

from rust-cross.

mzji avatar mzji commented on May 18, 2024

@Emilgardis Yeah, but what I asked is adding this kind of thing, or this link, to the document.

from rust-cross.

Emilgardis avatar Emilgardis commented on May 18, 2024

https://github.com/japaric/rust-cross#the-target-triple

https://github.com/japaric/rust-cross#cross-compiling-with-rustc

https://github.com/japaric/rust-cross#cross-compiling-with-cargo

How do those not explain how to cross-compile for different targets? (I am sorry if I sound rude, I'm just trying to understand what you want to improve on)

from rust-cross.

Emilgardis avatar Emilgardis commented on May 18, 2024

That does seem like something that is missing. Maybe a more general example could be done or the TL;DR could be generalized for any (supported) target.

from rust-cross.

mzji avatar mzji commented on May 18, 2024

Cross compiling from Win32 to Win64 (or vise versa) is easy, to some extent:

  1. rustup target add i686-pc-windows-msvc/x86_64-pc-windows-msvc
  2. cargo build --target i686-pc-windows-msvc/x86_64-pc-windows-msvc
  3. Done!

Sometimes you may need to check the portability of your binary if some asm/C/C++ code is involved, in other situations these steps just work. However, in Linux/macOS world, things may different.
Maybe a hello world example (.Net Core uses this example to show its cross-compiling ability) is enough? I don't sure about this.

from rust-cross.

avkonst avatar avkonst commented on May 18, 2024

When I run rustup on Windows it warns that I need to install C++ build tools, which I might get from Visual Studio. When I install Visual Studio, I can choose 2 packages: Windows development with C++ and Linux development with C++. If I install both, would it be possible to build binaries for linux on windows?

from rust-cross.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.