Close

Building SerialPlot for Windows using Docker

A project log for SerialPlot - Realtime Plotting Software

Small and simple software for plotting data from serial port

hasan-yavuz-zderyaHasan Yavuz Ă–zderya 09/14/2020 at 11:020 Comments

Building serialplot on windows isn't much different than building on linux. But it isn't as straightforward. Installing dependencies can be difficult. And it is also difficult to build a static EXE that doesn't require DLLs to keep it company. But most importantly it is difficult for me, because I don't use windows other than for gaming purposes. Unfortunately most users of SerialPlot use windows and as a result I can't ignore it.

Luckily there is MXE to my rescue. This is a cross compilation toolchain to build windows binaries (and more) on a linux (unix like) host. Whats more is that they also provide 'static' toolchains. When you build your project with a static toolchain it is easier to deploy and can be smaller in size.

So I prepared a dockerfile to make it even easier to build windows using docker. You can build this docker image on linux. AFAIK there are ways to run docker on windows host but I won't go into any details of that. It is also possible to use MXE in msys2, which is a layer to run unix programs on windows. In fact most of the windows releases until now has been built on windows using msys2 and mxe.

Dockerfile is already included in the serialplot source code called:

Dockerfile_mxe

Assuming you have already installed docker, download the serialplot source code using mercurial and build the docker image:

hg clone https://hg.sr.ht/~hyozd/serialplot/
cd serialplot
sudo docker build -t serialplot_mxe -f Dockerfile_mxe ./

Remember this might easily take a couple hours depending on your internet speed and cpu power. To give you an idea resulting docker image is around 5GB in size.

If all goes well you can get the built binary from inside the docker image with this command:

sudo docker run --rm --entrypoint cat serialplot_mxe /serialplot/build_docker_mxe/serialplot.exe > ../serialplot.exe 


Discussions