Problem building ArduSub on MacOS, error with math.h and gcc

I followed the directions from Build ArduSub · GitBook but getting build errors.

I may have confused using the new compiler with the older one (as stated in debugging), but not sure how to fix it. Anyone else have this problem?

My goal is to build a custom frame to support our ROV configuration.

af: Entering directory `/Users/s-uas/ArduSub/ardupilot/build/Pixhawk4’
Embedding file sandbox.lua:libraries/AP_Scripting/scripts/sandbox.lua
Embedding file io_firmware.bin:Tools/IO_Firmware/iofirmware_lowpolh.bin
Embedding file bootloader.bin:/Users/s-uas/ArduSub/ardupilot/Tools/bootloaders/Pixhawk4_bl.bin
Checking for env.py
env added DEFAULT_PARAMETERS=/Users/s-uas/ArduSub/ardupilot/libraries/AP_HAL_ChibiOS/hwdef/Pixhawk4/defaults.parm
env added MAIN_STACK=0x400
env added APJ_BOARD_TYPE=STM32F767xx
env added OPTIMIZE=-O2
env added BOARD_FLASH_SIZE=2048
env added APJ_BOARD_ID=50
env added HAL_WITH_UAVCAN=1
env added FLASH_RESERVE_START_KB=32
env added CHIBIOS_BUILD_FLAGS=USE_FATFS=yes MCU=cortex-m4 ENV_UDEFS=-DCHPRINTF_USE_FLOAT=1 CHIBIOS_PLATFORM_MK=os/hal/ports/STM32/STM32F7xx/platform.mk CHIBIOS_STARTUP_MK=os/common/startup/ARMCMx/compilers/GCC/mk/startup_stm32f7xx.mk
env added IOMCU_FW=0
env appended CPU_FLAGS=[‘-mcpu=cortex-m4’, ‘-mfpu=fpv4-sp-d16’, ‘-mfloat-abi=hard’, ‘-u_printf_float’]
env added PERIPH_FW=0
env added PROCESS_STACK=0x2000
[ 14/567] Compiling libraries/AC_Avoidance/AP_OADatabase.cpp
[ 16/567] Compiling libraries/AC_Avoidance/AP_OAVisGraph.cpp
[ 27/567] Compiling libraries/AC_WPNav/AC_WPNav.cpp
[ 28/567] Compiling libraries/AC_WPNav/AC_Loiter.cpp
[ 29/567] Compiling libraries/AC_WPNav/AC_Circle.cpp
[ 30/567] Compiling libraries/AP_ADC/AP_ADC_ADS1115.cpp
[ 31/567] Compiling libraries/AP_AHRS/AP_AHRS_View.cpp
[ 32/567] Compiling libraries/AP_AHRS/AP_AHRS_NavEKF.cpp
In file included from …/…/libraries/AP_Common/missing/cmath:3,
from …/…/libraries/AP_HAL/CAN.h:23,
from …/…/libraries/AP_HAL/HAL.h:17,
from …/…/libraries/AP_HAL/AP_HAL_Main.h:19,
from …/…/libraries/AP_HAL/AP_HAL.h:8,
from …/…/libraries/AC_Avoidance/AP_OAVisGraph.h:5,
from …/…/libraries/AC_Avoidance/AP_OAVisGraph.cpp:16:
/usr/local/Cellar/arm-none-eabi-gcc/9-2019-q4-major/gcc/arm-none-eabi/include/c++/9.2.1/cmath:83:11: error: ‘::acos’ has not been declared
83 | using ::acos;
| ^~~~
compilation terminated due to -Wfatal-errors.

In file included from …/…/libraries/AP_Common/missing/cmath:3,
from …/…/libraries/AP_HAL/CAN.h:23,
from …/…/libraries/AP_HAL/HAL.h:17,
from …/…/libraries/AP_HAL/AP_HAL_Main.h:19,
from …/…/libraries/AP_HAL/AP_HAL.h:8,
from …/…/libraries/AP_ADC/AP_ADC_ADS1115.cpp:1:
/usr/local/Cellar/arm-none-eabi-gcc/9-2019-q4-major/gcc/arm-none-eabi/include/c++/9.2.1/cmath:83:11: error: ‘::acos’ has not been declared
83 | using ::acos;
| ^~~~
compilation terminated due to -Wfatal-errors.

In file included from …/…/libraries/AP_Common/missing/cmath:3,
from …/…/libraries/AP_HAL/CAN.h:23,
from …/…/libraries/AP_HAL/HAL.h:17,
from …/…/libraries/AP_HAL/AP_HAL_Main.h:19,
from …/…/libraries/AP_HAL/AP_HAL.h:8,
from …/…/libraries/AC_Avoidance/AP_OADatabase.h:3,
from …/…/libraries/AC_Avoidance/AP_OADatabase.cpp:14:
/usr/local/Cellar/arm-none-eabi-gcc/9-2019-q4-major/gcc/arm-none-eabi/include/c++/9.2.1/cmath:83:11: error: ‘::acos’ has not been declared
83 | using ::acos;
| ^~~~
compilation terminated due to -Wfatal-errors.

In file included from …/…/libraries/AP_Common/missing/cmath:3,
from …/…/libraries/AP_HAL/CAN.h:23,
from …/…/libraries/AP_HAL/HAL.h:17,
from …/…/libraries/AP_HAL/AP_HAL_Main.h:19,
from …/…/libraries/AP_HAL/AP_HAL.h:8,
from …/…/libraries/AC_WPNav/AC_Loiter.cpp:1:
/usr/local/Cellar/arm-none-eabi-gcc/9-2019-q4-major/gcc/arm-none-eabi/include/c++/9.2.1/cmath:83:11: error: ‘::acos’ has not been declared
83 | using ::acos;
| ^~~~
compilation terminated due to -Wfatal-errors.

In file included from …/…/libraries/AP_Common/missing/cmath:3,
from …/…/libraries/AP_HAL/CAN.h:23,
from …/…/libraries/AP_HAL/HAL.h:17,
from …/…/libraries/AP_HAL/AP_HAL_Main.h:19,
from …/…/libraries/AP_HAL/AP_HAL.h:8,
from …/…/libraries/AC_WPNav/AC_Circle.cpp:1:
/usr/local/Cellar/arm-none-eabi-gcc/9-2019-q4-major/gcc/arm-none-eabi/include/c++/9.2.1/cmath:83:11: error: ‘::acos’ has not been declared
83 | using ::acos;
| ^~~~
compilation terminated due to -Wfatal-errors.

In file included from …/…/libraries/AP_Common/missing/cmath:3,
from …/…/libraries/AP_HAL/CAN.h:23,
from …/…/libraries/AP_HAL/HAL.h:17,
from …/…/libraries/AP_HAL/AP_HAL_Main.h:19,
from …/…/libraries/AP_HAL/AP_HAL.h:8,
from …/…/libraries/AP_AHRS/AP_AHRS_NavEKF.cpp:21:
/usr/local/Cellar/arm-none-eabi-gcc/9-2019-q4-major/gcc/arm-none-eabi/include/c++/9.2.1/cmath:83:11: error: ‘::acos’ has not been declared
83 | using ::acos;
| ^~~~
compilation terminated due to -Wfatal-errors.

In file included from …/…/libraries/AP_Filesystem/AP_Filesystem_FATFS.h:7,
from …/…/libraries/AP_Filesystem/AP_Filesystem.h:33,
from …/…/libraries/AP_Terrain/AP_Terrain.h:20,
from …/…/libraries/AC_WPNav/AC_WPNav.h:10,
from …/…/libraries/AC_WPNav/AC_WPNav.cpp:2:
…/…/libraries/AP_Common/missing/fcntl.h:8: warning: “O_CLOEXEC” redefined
8 | #define O_CLOEXEC 0
|
In file included from /usr/local/Cellar/arm-none-eabi-gcc/9-2019-q4-major/gcc/arm-none-eabi/include/sys/fcntl.h:4,
from /usr/local/Cellar/arm-none-eabi-gcc/9-2019-q4-major/gcc/arm-none-eabi/include/fcntl.h:1,
from …/…/libraries/AP_Common/missing/fcntl.h:1,
from …/…/libraries/AP_Filesystem/AP_Filesystem_FATFS.h:7,
from …/…/libraries/AP_Filesystem/AP_Filesystem.h:33,
from …/…/libraries/AP_Terrain/AP_Terrain.h:20,
from …/…/libraries/AC_WPNav/AC_WPNav.h:10,
from …/…/libraries/AC_WPNav/AC_WPNav.cpp:2:
/usr/local/Cellar/arm-none-eabi-gcc/9-2019-q4-major/gcc/arm-none-eabi/include/sys/_default_fcntl.h:62: note: this is the location of the previous definition
62 | #define O_CLOEXEC _FNOINHERIT
|
In file included from …/…/libraries/AP_Common/missing/cmath:3,
from …/…/libraries/AP_HAL/CAN.h:23,
from …/…/libraries/AP_HAL/HAL.h:17,
from …/…/libraries/AP_HAL/AP_HAL_Main.h:19,
from …/…/libraries/AP_HAL/AP_HAL.h:8,
from …/…/libraries/AC_WPNav/AC_WPNav.cpp:1:
/usr/local/Cellar/arm-none-eabi-gcc/9-2019-q4-major/gcc/arm-none-eabi/include/c++/9.2.1/cmath:83:11: error: ‘::acos’ has not been declared
83 | using ::acos;
| ^~~~
compilation terminated due to -Wfatal-errors.

Waf: Leaving directory `/Users/s-uas/ArduSub/ardupilot/build/Pixhawk4’
Build failed
→ task in ‘objs/AC_Avoidance’ failed (exit status 1):
{task 4378524200: cxx AP_OAVisGraph.cpp → AP_OAVisGraph.cpp.0.o}
(run with -v to display more information)
→ task in ‘objs/AP_ADC’ failed (exit status 1):
{task 4377673432: cxx AP_ADC_ADS1115.cpp → AP_ADC_ADS1115.cpp.0.o}
(run with -v to display more information)
→ task in ‘objs/AC_Avoidance’ failed (exit status 1):
{task 4378523840: cxx AP_OADatabase.cpp → AP_OADatabase.cpp.0.o}
(run with -v to display more information)
→ task in ‘objs/AC_WPNav’ failed (exit status 1):
{task 4378604920: cxx AC_Loiter.cpp → AC_Loiter.cpp.0.o}
(run with -v to display more information)
→ task in ‘objs/AC_WPNav’ failed (exit status 1):
{task 4378604800: cxx AC_Circle.cpp → AC_Circle.cpp.0.o}
(run with -v to display more information)
→ task in ‘objs/AP_AHRS’ failed (exit status 1):
{task 4377711512: cxx AP_AHRS_NavEKF.cpp → AP_AHRS_NavEKF.cpp.0.o}
(run with -v to display more information)
→ task in ‘objs/AC_WPNav’ failed (exit status 1):
{task 4378605040: cxx AC_WPNav.cpp → AC_WPNav.cpp.0.o}
(run with -v to display more information)
S-UAS

Hi. Were you able to solve the issue? I’m having the same problem on Ubuntu 20.04

Hi @osmanpasha, welcome to the forum :slight_smile:

I remember there being an issue with our build process for Ubuntu 20.04 a little while back, but unfortunately don’t think it finished getting fixed. From memory it’s an issue with the installing prerequisites step - the script in ArduSub-stable is outdated for Ubuntu Focal. We were discussing updating it to the one currently in the master branch, but @williangalvani pointed out that the latest commit for that file would likely cause issues with our existing system. It may work if you install using the master script, but you likely need to roll back to before that commit.

I’ve brought this up with the software team so we can figure out what needs to be updated/changed, but I’m not sure how soon we’ll be able to get the script updated correctly. If you decide to try it then please let us know how it goes :slight_smile:

Perhaps also worth noting this post, where the user apparently got around the issue by building with the Eclipse IDE.

1 Like

Hi! Thank you reply! Here is my progress so far:
I’ve tried building ardusub-stable branch with arm-none-eabi 9.2.1 on Ubuntu 20.04 and got this ::acos not defined error.
Then I’ve tried building with a docker container from repository. It uses ancient ubuntu 16.04 and fails somewhere during docker build.
Then I’ve tried building a docker container from master branch, and it succeeded (it is based on recent ubuntu 20.04 and uses arm-none-eabi-gcc 10.2.1). Unfortunately, that container failed to build ardusub from ardusub-stable branch with that same acos error. However, it did build ardusub from master branch. The problem is, I don’t know the status of that branch, how stable and how functional the binary is. (The branches separated in 2019 and I have not found the information on how they are synced)

This PR from 2019 fixes compilation on recent compilers, but it’s not in ardusub-stable. Applying those changes and adding some more fixes, I’ve managed to build ardusub-stable with up-to-date compiler. I am yet to test if it works though.

1 Like

FYI, @williangalvani managed to set aside some time for a proper look today, and has now found and merged the relevant PRs into his fork. I tested it on a fresh install of Ubuntu 20.04 and building worked fine, so we’ll be making a PR to the ardupilot repo tomorrow :slight_smile:

The PR is here, if anyone wants to follow along:

At this point we’re testing to see whether we also need to update the prerequisite scripts for stable Mac and Windows too.

Great work!
By the way, is git repository workflow regarding ardusub documented anywhere? I see that all the work on ardupilot, ardusub included, is done in master branch, however I don’t see where the release branches of ardusub pull or cherrypick stuff from it, and it branched from master somewhere in 2019. There are tons of changes between master and Ardusub-stable branch, and tag Ardudub-4.0.3 is much more recent than Sub-4.1 branch.

At this stage, not that I’m aware of.

I joined the team in mid May so am missing a chunk of relevant context, but working from the current state of things we’re definitely planning to improve the developer experience and relevant documentation. One of the major goals of my StaROV project is finding and fixing missing/outdated information that would be required/helpful for design and development using our components and software :slight_smile:

Sub-4.1 is a bit of a weird one - it’s currently used to support beta DVL functionality, but we’re expecting to skip straight to 4.2 for the next stable release, which I believe will be taken directly from master (this issue is perhaps relevant).