Cross Compilation Problem


I have a Problem with cross compilation. I want to compile some C++ Source Code for the ev3dev embedded Device.

This is my shell.nix file

with import <nixpkgs> {
  crossSystem = {
    config = "arm-unknown-linux-gnueabi";
    platform = {
      name = "ev3dev";
      kernelMajor = "3.2";
      kernelDTB = true;
      kernelArch = "arm";
      kernelAutoModules = true;
      kernelPreferBuiltin = true;
      kernelTarget = "zImage";

mkShell {
  buildInputs = [ gcc ];

When i use nix-shell shell.nix and then compile a simple hello world source code, everything works as expected on the device.
When I use the ev3dev library in my source code, I can compile everything, but when I try to execute the binary on the device, I get the following error:

./ev3drive : /lib/arm-linux-gnueabi/ : version GLIBC_2.27 not found (required by ./ev3drive)

The OS on the device uses GLIBC version 2.24 and NixOS uses versions 2.27. Is there a way to compile everything with GLIBC version 2.24?

Without testing it, you might be able to override the glibc package for your derivation. You can find the glibc derivation in the NixOS source in pkgs/development/libraries/glibc. I tried just changing it to 2.24, but the patches don’t apply, so you might have to see what they do. The last commit with that version seems to be 41fd1ed90346a3d7f6b067301ac9e147ef4dcd5e.

I’m not sure though if you can have a different package set for your crosscompiler itself and your target. So it might be necessary to build the crosscompiler itself against glibc 2.24.

1 Like

Ideally you would also link against the same glibc they use on their system.
Do they provide an SDK for that?

1 Like

I’ve tried this, but I can’t get it to build. There is an error during the compilation of glibc, because of the newer version of binutils. I’ve also tried to overwrite binutils with an older version, but I got no luck. This is above my skill level.

Now, I compile my source code statically. I add glibc.static to my buildInputs and then add the -static flag for the compiler. This seems to work for me, although this is not optimal.

1 Like