Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Dockcross: Cross compiling toolchains in Docker images (github.com/dockcross)
79 points by ingve on Feb 28, 2019 | hide | past | favorite | 16 comments


I was recently looking into something like this. It turns out Fedora is a cross compiling (at least for Windows) powerhouse. It has the compilers but _also_ cross-built packages for most standard system libraries (libpng, curl, etc).

This is turning into a random info dump, but whatever.

Azure Pipelines has free Windows workers in their pool, for open source, with all standard Windows build tools, python, etc. I'm not aware of other CI providers with Windows instances.

I wanted to use Guix but wanted to try it out with Docker and there aren't any official packages, ran into a number of issues setting it up manually. Guix has their libraries and build environments abstracted in such a way that it should be possible to build any package with say mingw in a line (or two). Guix also seems to have a stricter versioning system than Nix, where it didn't look trivial to pin specific package/system versions.

Gnome msitools has a Wix clone for Windows MSI creation. It's a bit hobbled (doesn't support a lot of fields/parameters).


Appveyor also has free Windows CI for open source projects


Quiet nice to have a curated list of compilers available. However I think the pain starts when it comes to compiling libraries and programs, where the buildsystem is not designed to be cross-compiled. In nixpkgs, where have now also cross-compile support, we had to add quiet a few patches and little fixes to some libraries.


I hope an effort was made to upstream such patches as well?


When I had a need for a Dockered cross-compiler, I found that Gentoo and crossdev [0] were amazing. Because of Gentoo's philosophy of distributing source only, the toolchain was built inside the container, and using fresh versions of each tool.

A few additional steps were involved with setting up an overlay, but it was smooth sailing from there, and people on #gentoo-mips were eager to help.

[0] https://wiki.gentoo.org/wiki/Cross_build_environment


For a single image approach and osx support, see: https://github.com/multiarch/crossbuild


To use this for anything serious, you have to know exactly how these images are built. In fact, you should just build them all from the source yourself. Consequences of using unvetted compilers/toolchain are severe, and pulling build tools from Docker Hub is something you should often try to avoid.

I like the idea in practice. Assuming you're already on a cross-compiled project, this could vastly make your job easier and you can script around this very easily.


Tangential question, is there a canonical way to build cross-platform docker images without using docker hub? For example, armhf on an x86. I've seen some stuff from Balena, but nothing that looks particularly straight forward.

Unless I misunderstand, docker cross is simply for cross compiling apps.

I've been experimenting a lot with embedded boards and compiling a couple of large libraries on a Pi can take all night.


Yes, I don't know if this is the canonical way but you can use QEMU to build them [0].

[0] https://servicelab.org/2018/09/13/platform-aware-docker-imag...


If you need to do cross-compiling but not enough to do it in docker containers, ct-ng (crosstools-ng) is awesome.

It is kinda self-hosting in the sense that you unpack its release in a directory and all its files are going to stay there, including the cross-toolchain that you build.

And, of course, it can automatically build toolchains for a wide range of architectures, all while being fairly configurable.


My dream is to compile windows UI applications from Docker while staying on a Linux host


You can certainly achieve this by installing MinGW cross compilers in a Docker image. Many major distros have MinGW packages, and some CI setups use exactly this setup.

(For good measure, an example would be OpenRCT2 which maintains Dockerfiles for cross compiling, like this one: https://github.com/OpenRCT2/OpenRCT2/blob/develop/dockerfile... )


We do that quite easily for all VideoLAN projects, using https://code.videolan.org/videolan/docker-images/tree/master...


DM me. We're looking for beta users


Try Nixpkgs


Doing god's own work.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: