在x86_64机器上rust编译x86库 [英] rust compile x86 library on x86_64 machine

查看:144
本文介绍了在x86_64机器上rust编译x86库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有ubuntu x86_64容器,货物建造进行得很顺利.但是我也需要建立x86库版本.据我了解,我需要添加i686工具链和目标.

I have ubuntu x86_64 container and cargo build goes well. But i need to build x86 library version too. As far as I understand i need to add i686 toolchain and target.

rustup target add i686-unknown-linux-gnu done successful

rustup toolchain install stable-i686-unknown-linux-gnu finished with error

$ rustup toolchain install stable-i686-unknown-linux-gnu
info: syncing channel updates for 'stable-i686-unknown-linux-gnu'
info: latest update on 2018-11-08, rust version 1.30.1 (1433507eb 2018-11-07)
info: downloading component 'rustc'
info: downloading component 'rust-std'
info: downloading component 'cargo'
info: downloading component 'rust-docs'
info: installing component 'rustc'
info: installing component 'rust-std'
info: installing component 'cargo'
info: installing component 'rust-docs'

  stable-i686-unknown-linux-gnu installed - (error reading rustc version)

$ rustup  default stable-i686
info: using existing install for 'stable-i686-unknown-linux-gnu'
info: default toolchain set to 'stable-i686-unknown-linux-gnu'

  stable-i686-unknown-linux-gnu unchanged - (error reading rustc version)

我错过了什么还是采取了错误的方法?

Do I missed something or took wrong approach?

推荐答案

您无需更改工具链,而必须将目标添加到当前工具链(请确保先切换回原始工具链).

Instead of changing your toolchain, you have to add the target to your current toolchain (make sure to switch back to your original toolchain first).

$ rustup target install i686-unknown-linux-gnu
$ cargo build --target=i686-unknown-linux-gnu

当然,您还需要在系统上安装32位库,例如在ubuntu上,您可以通过以下方式安装它们:

Of course, you need to install the 32-bit libraries on your system as well, e.g. on ubuntu you install them by

$ sudo apt install gcc-multilib

(有关该信息的更多信息,请参见如何在64位Ubuntu上编译32位应用程序?)

(for more information about that see How to Compile 32-bit Apps on 64-bit Ubuntu?)

这篇关于在x86_64机器上rust编译x86库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆