1

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?

3
  • 1
    It is compiler dependent, which compiler are you using? Commented Mar 8, 2022 at 15:22
  • 1
    I don't know about Apple, but on Linux systems you can typically install a specific cross-compiler for the target system. Maybe take a look in your repository? Commented Mar 8, 2022 at 15:27
  • 1
    Use a compiler that can target Ubuntu x86. The g++ compiler has many variations. Commented Mar 8, 2022 at 17:29

2 Answers 2

5

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Here, the command is x86_64-linux-gnu-gcc (replace - with _)
1

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

2 Comments

localhost:6080/vnc.html is a local link, not something people can access
@phuclv: After running that docker command, with that ports opened up, it should be accessible from the same computer. Looks like the edit following your comment was an improvement, showing the text of the link instead of just having it as a hyperlink behind some other text. Indeed that was weird.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.