Build fails with WSL on Windows 10

Hi everyone,

I’m trying to compile ArduCopter 3.6, but I’m constantly failing. I followed the documentation to set up the build environment. So far everything went fine, except for this line:

denkste@DESKTOP-BQ07HT2:/mnt/c/Users/User/Documents/GitHub/ardupilot/Tools/scripts$ sudo add-apt-repository ppa:terry.guo/gcc-arm-embedded
 tag:launchpad.net:2008:redacted
 More info: https://launchpad.net/~terry.guo/+archive/ubuntu/gcc-arm-embedded
Press [ENTER] to continue or ctrl-c to cancel adding it
gpg: keyring `/tmp/tmpgn9074xz/secring.gpg' created
gpg: keyring `/tmp/tmpgn9074xz/pubring.gpg' created
gpg: "tag:launchpad.net:2008:redacted" not a key ID: skipping
Failed to add key.

Because the next commands didn’t result in any errors, I was hoping to be lucky and tried to build. The config looked ok for me:

denkste@DESKTOP-BQ07HT2:/mnt/c/Users/User/Documents/GitHub/ardupilot$ ./waf configure --board px4-v3
Setting top to                           : /mnt/c/Users/User/Documents/GitHub/ardupilot
Setting out to                           : /mnt/c/Users/User/Documents/GitHub/ardupilot/build
Autoconfiguration                        : enabled
Setting board to                         : px4-v3
Checking for program 'arm-none-eabi-ar'  : /usr/bin/arm-none-eabi-ar
Using toolchain                          : arm-none-eabi
Checking for 'g++' (C++ compiler)        : /usr/bin/arm-none-eabi-g++
Checking for 'gcc' (C compiler)          : /usr/bin/arm-none-eabi-gcc
Checking for HAVE_CMATH_ISFINITE         : no
Checking for HAVE_CMATH_ISINF            : no
Checking for HAVE_CMATH_ISNAN            : no
Checking for NEED_CMATH_ISFINITE_STD_NAMESPACE : no
Checking for NEED_CMATH_ISINF_STD_NAMESPACE    : no
Checking for NEED_CMATH_ISNAN_STD_NAMESPACE    : no
Checking for header endian.h                   : not found
Checking for header byteswap.h                 : not found
Checking for program 'cmake'                   : /usr/bin/cmake
Checking cmake version                         : 3.5.2
Checking for program 'ninja, ninja-build'      : not found
Checking for program 'make'                    : /usr/bin/make
Checking for program 'python'                  : /usr/bin/python
Checking for python version >= 2.7.0           : 2.7.12
Checking for program 'python'                  : /usr/bin/python
Checking for python version >= 2.7.0           : 2.7.12
Source is git repository                       : yes
Update submodules                              : yes
Checking for program 'git'                     : /usr/bin/git
Gtest                                          : STM32 boards currently don't support compiling gtest
Checking for program 'arm-none-eabi-size'      : /usr/bin/arm-none-eabi-size
Benchmarks                                     : disabled
Unit tests                                     : disabled
Checking for program 'rsync'                   : /usr/bin/rsync
'configure' finished successfully (2.601s)

But trying to build resulted like this:

denkste@DESKTOP-BQ07HT2:/mnt/c/Users/User/Documents/GitHub/ardupilot$ ./waf copter
Waf: Entering directory `/mnt/c/Users/User/Documents/GitHub/ardupilot/build/px4-v3'
[ 9/15] Processing uavcangen: modules/uavcan/dsdl/uavcan/CoarseOrientation.uavcan modules/uavcan/dsdl/uavcan/Timestamp.uavcan modules/uavcan/dsdl/uavcan/equipment/actuator/1010.ArrayCommand.uavcan modules/uavcan/dsdl/uavcan/equipment/actuator/1011.Status.uavcan modules/uavcan/dsdl/uavcan/equipment/actuator/Command.uavcan modules/uavcan/dsdl/uavcan/equipment/ahrs/1000.Solution.uavcan modules/uavcan/dsdl/uavcan/equipment/ahrs/1001.MagneticFieldStrength.uavcan modules/uavcan/dsdl/uavcan/equipment/ahrs/1002.MagneticFieldStrength2.uavcan modules/uavcan/dsdl/uavcan/equipment/ahrs/1003.RawIMU.uavcan modules/uavcan/dsdl/uavcan/equipment/air_data/1020.TrueAirspeed.uavcan modules/uavcan/dsdl/uavcan/equipment/air_data/1021.IndicatedAirspeed.uavcan modules/uavcan/dsdl/uavcan/equipment/air_data/1025.AngleOfAttack.uavcan modules/uavcan/dsdl/uavcan/equipment/air_data/1026.Sideslip.uavcan modules/uavcan/dsdl/uavcan/equipment/air_data/1027.RawAirData.uavcan modules/uavcan/dsdl/uavcan/equipment/air_data/1028.StaticPressure.uavcan modules/uavcan/dsdl/uavcan/equipment/air_data/1029.StaticTemperature.uavcan modules/uavcan/dsdl/uavcan/equipment/camera_gimbal/1040.AngularCommand.uavcan modules/uavcan/dsdl/uavcan/equipment/camera_gimbal/1041.GEOPOICommand.uavcan modules/uavcan/dsdl/uavcan/equipment/camera_gimbal/1044.Status.uavcan modules/uavcan/dsdl/uavcan/equipment/camera_gimbal/Mode.uavcan modules/uavcan/dsdl/uavcan/equipment/device/1110.Temperature.uavcan modules/uavcan/dsdl/uavcan/equipment/esc/1030.RawCommand.uavcan modules/uavcan/dsdl/uavcan/equipment/esc/1031.RPMCommand.uavcan modules/uavcan/dsdl/uavcan/equipment/esc/1034.Status.uavcan modules/uavcan/dsdl/uavcan/equipment/gnss/1060.Fix.uavcan modules/uavcan/dsdl/uavcan/equipment/gnss/1061.Auxiliary.uavcan modules/uavcan/dsdl/uavcan/equipment/gnss/1062.RTCMStream.uavcan modules/uavcan/dsdl/uavcan/equipment/gnss/1063.Fix2.uavcan modules/uavcan/dsdl/uavcan/equipment/gnss/ECEFPositionVelocity.uavcan modules/uavcan/dsdl/uavcan/equipment/hardpoint/1070.Command.uavcan modules/uavcan/dsdl/uavcan/equipment/hardpoint/1071.Status.uavcan modules/uavcan/dsdl/uavcan/equipment/ice/1129.FuelTankStatus.uavcan modules/uavcan/dsdl/uavcan/equipment/ice/reciprocating/1120.Status.uavcan modules/uavcan/dsdl/uavcan/equipment/ice/reciprocating/CylinderStatus.uavcan modules/uavcan/dsdl/uavcan/equipment/indication/1080.BeepCommand.uavcan modules/uavcan/dsdl/uavcan/equipment/indication/1081.LightsCommand.uavcan modules/uavcan/dsdl/uavcan/equipment/indication/RGB565.uavcan modules/uavcan/dsdl/uavcan/equipment/indication/SingleLightCommand.uavcan modules/uavcan/dsdl/uavcan/equipment/power/1090.PrimaryPowerSupplyStatus.uavcan modules/uavcan/dsdl/uavcan/equipment/power/1091.CircuitStatus.uavcan modules/uavcan/dsdl/uavcan/equipment/power/1092.BatteryInfo.uavcan modules/uavcan/dsdl/uavcan/equipment/range_sensor/1050.Measurement.uavcan modules/uavcan/dsdl/uavcan/equipment/safety/1100.ArmingStatus.uavcan modules/uavcan/dsdl/uavcan/navigation/2000.GlobalNavigationSolution.uavcan modules/uavcan/dsdl/uavcan/protocol/1.GetNodeInfo.uavcan modules/uavcan/dsdl/uavcan/protocol/2.GetDataTypeInfo.uavcan modules/uavcan/dsdl/uavcan/protocol/341.NodeStatus.uavcan modules/uavcan/dsdl/uavcan/protocol/4.GetTransportStats.uavcan modules/uavcan/dsdl/uavcan/protocol/4.GlobalTimeSync.uavcan modules/uavcan/dsdl/uavcan/protocol/5.Panic.uavcan modules/uavcan/dsdl/uavcan/protocol/5.RestartNode.uavcan modules/uavcan/dsdl/uavcan/protocol/6.AccessCommandShell.uavcan modules/uavcan/dsdl/uavcan/protocol/CANIfaceStats.uavcan modules/uavcan/dsdl/uavcan/protocol/DataTypeKind.uavcan modules/uavcan/dsdl/uavcan/protocol/HardwareVersion.uavcan modules/uavcan/dsdl/uavcan/protocol/SoftwareVersion.uavcan modules/uavcan/dsdl/uavcan/protocol/debug/16370.KeyValue.uavcan modules/uavcan/dsdl/uavcan/protocol/debug/16383.LogMessage.uavcan modules/uavcan/dsdl/uavcan/protocol/debug/LogLevel.uavcan modules/uavcan/dsdl/uavcan/protocol/dynamic_node_id/1.Allocation.uavcan modules/uavcan/dsdl/uavcan/protocol/dynamic_node_id/server/30.AppendEntries.uavcan modules/uavcan/dsdl/uavcan/protocol/dynamic_node_id/server/31.RequestVote.uavcan modules/uavcan/dsdl/uavcan/protocol/dynamic_node_id/server/390.Discovery.uavcan modules/uavcan/dsdl/uavcan/protocol/dynamic_node_id/server/Entry.uavcan modules/uavcan/dsdl/uavcan/protocol/enumeration/15.Begin.uavcan modules/uavcan/dsdl/uavcan/protocol/enumeration/380.Indication.uavcan modules/uavcan/dsdl/uavcan/protocol/file/40.BeginFirmwareUpdate.uavcan modules/uavcan/dsdl/uavcan/protocol/file/45.GetInfo.uavcan modules/uavcan/dsdl/uavcan/protocol/file/46.GetDirectoryEntryInfo.uavcan modules/uavcan/dsdl/uavcan/protocol/file/47.Delete.uavcan modules/uavcan/dsdl/uavcan/protocol/file/48.Read.uavcan modules/uavcan/dsdl/uavcan/protocol/file/49.Write.uavcan modules/uavcan/dsdl/uavcan/protocol/file/EntryType.uavcan modules/uavcan/dsdl/uavcan/protocol/file/Error.uavcan modules/uavcan/dsdl/uavcan/protocol/file/Path.uavcan modules/uavcan/dsdl/uavcan/protocol/param/10.ExecuteOpcode.uavcan modules/uavcan/dsdl/uavcan/protocol/param/11.GetSet.uavcan modules/uavcan/dsdl/uavcan/protocol/param/Empty.uavcan modules/uavcan/dsdl/uavcan/protocol/param/NumericValue.uavcan modules/uavcan/dsdl/uavcan/protocol/param/Value.uavcan modules/uavcan/dsdl/uavcan/tunnel/2010.Broadcast.uavcan modules/uavcan/dsdl/uavcan/tunnel/63.Call.uavcan modules/uavcan/dsdl/uavcan/tunnel/Protocol.uavcan
Compiler failure
Traceback (most recent call last):
  File "/mnt/c/Users/User/Documents/GitHub/ardupilot/modules/uavcan/libuavcan/dsdl_compiler/libuavcan_dsdlc", line 61, in <module>
    dsdlc_run(args.source_dir, args.incdir, args.outdir)
  File "/mnt/c/Users/User/Documents/GitHub/ardupilot/modules/uavcan/libuavcan/dsdl_compiler/libuavcan_dsdl_compiler/__init__.py", line 62, in run
    run_generator(types, output_dir)
  File "/mnt/c/Users/User/Documents/GitHub/ardupilot/modules/uavcan/libuavcan/dsdl_compiler/libuavcan_dsdl_compiler/__init__.py", line 111, in run_generator
    die(ex)
  File "/mnt/c/Users/User/Documents/GitHub/ardupilot/modules/uavcan/libuavcan/dsdl_compiler/libuavcan_dsdl_compiler/__init__.py", line 89, in die
    raise DsdlCompilerException(str(text))
DsdlCompilerException: line 16, col 17: invalid syntax (, line 1)
line 16, col 17: invalid syntax (, line 1)

uavcangen returned 1 error code
Waf: Leaving directory `/mnt/c/Users/User/Documents/GitHub/ardupilot/build/px4-v3'
Traceback (most recent call last):
  File "/mnt/c/Users/User/Documents/GitHub/ardupilot/modules/waf/waflib/Scripting.py", line 165, in waf_entry_point
    run_commands()
  File "/mnt/c/Users/User/Documents/GitHub/ardupilot/modules/waf/waflib/Scripting.py", line 266, in run_commands
    ctx = run_command(cmd_name)
  File "/mnt/c/Users/User/Documents/GitHub/ardupilot/modules/waf/waflib/Scripting.py", line 250, in run_command
    ctx.execute()
  File "/mnt/c/Users/User/Documents/GitHub/ardupilot/modules/waf/waflib/Scripting.py", line 616, in execute
    return execute_method(self)
  File "/mnt/c/Users/User/Documents/GitHub/ardupilot/modules/waf/waflib/Build.py", line 255, in execute
    self.execute_build()
  File "/mnt/c/Users/User/Documents/GitHub/ardupilot/modules/waf/waflib/Build.py", line 275, in execute_build
    self.compile()
  File "/mnt/c/Users/User/Documents/GitHub/ardupilot/modules/waf/waflib/Build.py", line 377, in compile
    raise Errors.BuildError(self.producer.error)
  File "/mnt/c/Users/User/Documents/GitHub/ardupilot/modules/waf/waflib/Errors.py", line 45, in __init__
    WafError.__init__(self, self.format_error())
  File "/mnt/c/Users/User/Documents/GitHub/ardupilot/modules/waf/waflib/Errors.py", line 51, in format_error
    txt = tsk.format_error()
  File "/mnt/c/Users/User/Documents/GitHub/ardupilot/modules/waf/waflib/Task.py", line 415, in format_error
    txt = cmd
NameError: global name 'cmd' is not defined

I alredy tried git submodule update --recursive, but this didn’t change anything at all.

Any ideas?

Wiki is outdated.

First of all it won’t work via DrvFs (mnt/c…) directories, source must be on the “native” WSL filesystem.
Got latest Windows 10 (version 1803), add WSL from features, no need for developer mode anymore…
A fresh WSL ubuntu 16.04 install from the Store,
apt-get update
apt-get upgrade
git clone https://github.com/ardupilot/ardupilot.git
cd ardupilot
git submodule init
git submodule refresh --recursive
Tools/scripts/install-prereqs-ubuntu.sh -y
remove arm-none-earbi-ar from the path in ~/.profile (script installs i386 versio of compiller, which does not run under a x64 WSL (unlike in real linux)
apt-get install arm-none-eabi-ar
reload .profile

All set.

To make it more awesome :
Install VcXsrv on Xserver on Windows
add DISPLAY=:0 to your profile in WSL
Now, most of the xwindows apps will run… (including SITL)
For code editing you can install VSCode inside WSL (yes it runs since 1803)

3 Likes

Thank you so much! After tweaking around a lot in the last days I was for the first time able to compile sucessfully. I’ll try to update the wiki accordingly.

Just for the record: I couldn’t find the package “arm-none-eabi-ar”. Instead I installed “gcc-arm-none-eabi”. Was this the correct way? Or should I have added another repository?

1 Like

gcc-arm-none-eabi-ar is fine.
If you add the xserver as above you should be able to run the sitl map and console modules, which helps :slight_smile:
You can use a different terminal program too. I use conemu and mobaxterm which are working well with wsl.

Indeed the package name is gcc-arm-none-eabi, my bad.

Thanks very much @marcel for the wiki update! I just merged it.

It’s so great when, after solving a problem, people take that extra step to document it so it’s easier for the next person. … and thanks to @Eosbandi for helping out with this!

1 Like

Thanks, finally, this solved it for me after wasting 3 days on it.
I don’t have troubles getting it to compile on another computer though. With gcc 5.4.0 and arm-none-eabi 4.9.3 it works fine on my laptop.

I wonder what could be going on that /mnt/c/… drives don’t work? It’s just a file system - how could it be different from so called “native WSL” filesystem?

They are NTFS filesystems mounted through the DrvFs driver, some features are not or not correctly implemented in the DrvFs. (The problem is somewhere around long file path walk through) .“Native” WSL filesystem implements all extfs features via additional properties to the NTFS filesystem, these additional properties are managed by the WSL kernel emulator. These extra properties are the reason that you should not, under any circumstances, create and/or modify WSL files directly using Windows apps, tools, scripts, consoles, etc.

1 Like

I have the same issue when I compile under cygwin64 any ideas how to solve it ?

I think the instructions here are incorrect. I am building and running fine on WSL on NTFS drives mounted through WSL. The key point is the compiler version, WSL will only allow 64 bit executables to run and there is no 64 bit version of gcc 4-9 which is what 3.6 required. master is correct and installs the right version via Tools/environment_install/install-prereqs-ubuntu.sh and I have found this works for 3.6 also. The version I am using is:

andy@Eagle:/mnt/i/github/ardupilot-dev$ arm-none-eabi-gcc --version 
arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors 6-2017-q2-update) 6.3.1 20170620
(release) [ARM/embedded-6-branch revision 249437]

I have not found any other version to work successfully, in particular do not install this via apt-get, you will get something that appears to work but is subtly broken.

Don’t bother with cygwin, WSL on the latest versions of windows 10 is really pretty good now.

1 Like

Microsoft have just released this: https://code.visualstudio.com/docs/remote/wsl
It works really well - I highly recommend it. Working well for me with the cross compilers required by AP.

1 Like