如何将linuxarm交叉编译到x86

发布于 2025-01-12 13:12:51 字数 220 浏览 2 评论 0原文

我使用的是 m1 pro macbook pro。 到目前为止,我使用的是intel macbook。

我的程序是用c/c++编写的,目标是ubuntu x86_64。

我尝试运行 ubuntu x86 docker (qemu),它非常慢 - 以至于无法使用。 我使用并行安装了 linux ubuntu (arm),并且想针对 x86 目标而不是 arm 进行编译。

我该怎么做?

I'm using an m1 pro macbook pro.
Up until now, I used intel macbook.

My program is written in c/c++ and the target is ubuntu x86_64.

I tried running ubuntu x86 docker (qemu) and it's super slow - to the point it's unusable.
I have linux ubuntu (arm) installed using parallels and would like to compile for x86 target instead of arm.

How do I do it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

南街九尾狐 2025-01-19 13:12:51

在 Ubuntu 上,我建议使用 apt install gcc-x86-64-linux-gnu g++-x86-64-linux-gnu,然后使用 x86-64- 调用已安装的编译器linux-gnu 前缀(对于 gcc,x86-64-linux-gnu-gcc)来创建 x86_64 二进制文件。

请注意,如果您的目标为 x86_64,您将无法运行您本地构建的程序,但您应该能够打包为在 x86_64 计算机上执行而创建的二进制文件。

On Ubuntu, I would suggest an apt install gcc-x86-64-linux-gnu g++-x86-64-linux-gnu, and then invoking the installed compiler with the x86-64-linux-gnu prefix (for gcc, x86-64-linux-gnu-gcc) to create x86_64 binaries.

Do note that if you target x86_64 you won't be able to run the programs you build natively, but you should be able to package the binaries created for execution on an x86_64 machine.

不寐倦长更 2025-01-19 13:12:51

在您的 Mac 上安装 docker-desktop 并使用以下命令运行此 docker 容器:

docker container run --platform=linux/amd64 -it -p 6080:6080 -e WIDTH=1920 -e HEIGHT=1080 yoas1/xubuntu-desktop:1.0

不要忘记为代码目录创建卷。
在浏览器中访问:http://localhost:6080/vnc.html 访问 xubuntu 桌面

Dockerhub 上的图片

Install docker-desktop on your mac and run this docker container with the command:

docker container run --platform=linux/amd64 -it -p 6080:6080 -e WIDTH=1920 -e HEIGHT=1080 yoas1/xubuntu-desktop:1.0

Don't forget to create volume to the code directory.
In your browser go to: http://localhost:6080/vnc.html to access the xubuntu desktop

Image on Dockerhub

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文