Build Ardupilot SITL

Hi,

I’m currently trying to build Ardupilot SITL. The build is described here: ardupilot/BUILD.md at 8347a86d5952ea79b42a519d498fc77e4b979a6c · ArduPilot/ardupilot · GitHub

I have modified the shebang of the ardupilot/waf at 8347a86d5952ea79b42a519d498fc77e4b979a6c · ArduPilot/ardupilot · GitHub as described in the manual Nixpkgs Reference Manual

In the build process I use the following nix-shell.

let
  pkgs = import <nixpkgs> { };
  python = pkgs.python3.override {
    self = python;
    packageOverrides = pyfinal: pyprev: {
      empy = pyfinal.callPackage ./empy.nix { };
    };
  };
in
pkgs.mkShell {
  packages = [
    (python.withPackages (python-pkgs: [
      python-pkgs.dronecan
      python-pkgs.empy
      python-pkgs.pexpect
      python-pkgs.ptyprocess
      python-pkgs.pymavlink
      python-pkgs.pyserial
      python-pkgs.setuptools
    ]))
  ];
}

the first step is ./waf configure --board sitl which works fine. After this I execute ./waf copter and get the following error:

Embedding file locations.txt:Tools/autotest/locations.txt
Embedding file models/Callisto.json:Tools/autotest/models/Callisto.json
Embedding file models/freestyle.json:Tools/autotest/models/freestyle.json
Embedding file models/plane-3d.parm:Tools/autotest/models/plane-3d.parm
Embedding file models/plane.parm:Tools/autotest/models/plane.parm
Embedding file models/xplane_heli.json:Tools/autotest/models/xplane_heli.json
Embedding file models/xplane_plane.json:Tools/autotest/models/xplane_plane.json
[3/7] Compiling libraries/AP_Scripting/generator/src/main.c
In file included from /nix/store/n15bxkd7id2gvlwpihm4kp675aqkrwmj-glibc-2.40-36-dev/include/stdio.h:970,
                 from ../../libraries/AP_Scripting/generator/src/main.c:1:
In function ‘fprintf’,
    inlined from ‘emit_userdata_method’ at ../../libraries/AP_Scripting/generator/src/main.c:2049:5:
/nix/store/n15bxkd7id2gvlwpihm4kp675aqkrwmj-glibc-2.40-36-dev/include/bits/stdio2.h:111:10: error: ‘var_type_name’ may be used uninitialized [-Werror=maybe-uninitialized]
  111 |   return __fprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  112 |                         __va_arg_pack ());
      |                         ~~~~~~~~~~~~~~~~~
../../libraries/AP_Scripting/generator/src/main.c: In function ‘emit_userdata_method’:
../../libraries/AP_Scripting/generator/src/main.c:2014:11: note: ‘var_type_name’ was declared here
 2014 |     char *var_type_name;
      |           ^~~~~~~~~~~~~
cc1: all warnings being treated as errors

Does any one have an idea how I can fix this?

PS: some of the python packages in the shell.nix are only needed for running SITL as described here:
https://ardupilot.org/dev/docs/setting-up-sitl-on-linux.html

My empy.nix is just empy version 3.3.4.

Running the build on arch linux works. There I uses gcc version 14.2.1. In nix the unstable version is 13.3.0. I also tried to use gcc14 from nix unstable, but had no success.

1 Like