Issues with building APM from sources and failing

Attempting to build APM—below is a copy and paste. What am I doing wrong? I checked out navio as per the instructions in http://docs.emlid.com/Navio-APM/building-from-sources/

pi@navio-rpi ~/ardupilot/ArduCopter $ sudo make navio-hexa
// BUILDROOT=/tmp/ArduCopter.build HAL_BOARD=HAL_BOARD_LINUX HAL_BOARD_SUBTYPE=HAL_BOARD_SUBTYPE_LINUX_NAVIO TOOLCHAIN=RPI EXTRAFLAGS=-DGIT_VERSION=“0615d7a0” -DFRAME_CONFIG=HEXA_FRAME
%% control_rtl.o
cc1plus: error: unrecognized command line option ‘-std=gnu++11’
…/mk/build_rules.mk:11: recipe for target ‘/tmp/ArduCopter.build/control_rtl.o’ failed
make: *** [/tmp/ArduCopter.build/control_rtl.o] Error 1
pi@navio-rpi ~/ardupilot/ArduCopter $

Hi there,
I suggest to try out the master branch, because I don’t know about the state of the navio branch and I mainly use master.

git clone https://github.com/diydrones/ardupilot.git
cd ardupilot/ArduCopter
make navio-quad

Regarding the error. Which version of gcc do you have installed? For unknown reasons, something with your compiler might be wrong. E.g. the version installed is not supporting cxx11. I guess you need at min. gcc >= 4.7. However, I suggest to build at least with gcc >= 4.8. If you for any reason decided to use a different compiler such as clang, the build may work theoretically, but probably not with the current build system :slight_smile:

Best, Daniel

Thanks for the reply. I’m using the OS image downloaded from the Navio site so it came with gcc 4.6. I updated to 4.8.4 but same result using master:

pi@navio-rpi ~/ardupilot/ArduCopter $ gcc --version
gcc (Raspbian 4.8.4-1) 4.8.4
Copyright © 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

pi@navio-rpi ~/ardupilot/ArduCopter $ git checkout master
Already on 'master’
pi@navio-rpi ~/ardupilot/ArduCopter $ sudo make navio-hexa
// BUILDROOT=/tmp/ArduCopter.build HAL_BOARD=HAL_BOARD_LINUX HAL_BOARD_SUBTYPE=HAL_BOARD_SUBTYPE_LINUX_NAVIO TOOLCHAIN=RPI EXTRAFLAGS=-DGIT_VERSION=“5ef4f8e9” -DFRAME_CONFIG=HEXA_FRAME
%% control_rtl.o
cc1plus: error: unrecognized command line option ‘-std=gnu++11’
…/mk/build_rules.mk:11: recipe for target ‘/tmp/ArduCopter.build/control_rtl.o’ failed
make: *** [/tmp/ArduCopter.build/control_rtl.o] Error 1
pi@navio-rpi ~/ardupilot/ArduCopter $

Are you sure g++ has the right version as well?

at this point, not sure of anything but here are the versions:

i@navio-rpi ~ $ g++ --version
g++ (Raspbian 4.8.4-1) 4.8.4
Copyright © 2013 Free Software Foundation, Inc.

pi@navio-rpi ~ $ gcc --version
gcc (Raspbian 4.8.4-1) 4.8.4
Copyright © 2013 Free Software Foundation, Inc.
.

Still failing after multiple attempts. It might not have been clear but I am doing this directly on the RPI2. I found this thread that suggests others are having issues building on the RPI2 as well. I guess I’ll try to cross compile:

My guess is that cc1plus is a dynamic link and leading to the wrong g++ version :smile:
I still think it has to be a version conflict.

You are most likely right but I am using stock emlid/navio image for RPI2 and a following all the instructions from the documentation. So one or the other or both are in bad need of updates. I gave up trying to build the sources on the pi and just installed apm via the .deb so I can get things flying. I’ll work on the cross-compiling/building from sources on another day.

Okay, but cross compiling can also fail if the compiler environment is not configured as it should be …
If you compile something it is always helpful to know what is actually going on.

@Kevin_Goff

As @dgrat has rightfully mentioned above the issue does indeed boils down to a couple of wrong symlinks.

I assume you’ve installed the newer gcc. If that’s true these commands should get you going.
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 20
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50
sudo update-alternatives --install /usr/bin/arm-linux-gnueabihf-g++ arm-linux-gnueabihf-g++ /usr/bin/g++-4.8 50

The thing is the compilation will take a daunting amount of time. That’s why nobody’s bothered with a tutorial. The new image will however have a newer compiler.

Good luck !