Building ArduPilot on OSX with waf

@gmorph you are building for px4-v2 with clang? Is that intentional? I think this would happen in waf only if for some reason you have CXX env var set by mistake or you don’t have the toolchain in your path.

@guludo any idea?

@lucasdemarchi It seems @billb actually has the toolchain in his path:

Checking for program 'arm-none-eabi-size'      : /usr/local/bin/arm-none-eabi-size

Waf tries the clang compiler before gcc when checking for a compiler on OSX. @billb could you please share the output of the px4_msg_gen target? You’ve just posted the output of the configure step.

By what @gmorph’s posted, it seems that cross-compilation with clang is indeed broken.

A workaround is passing --check-gxx-compiler g++ to the configure command, so that it only finds the GNU compiler.

From my limited waf understanding on OSX it seems to look for clang first and if it finds it just uses that. I have gcc in my path :

MBPro1:~ grant$ which arm-none-eabi-size
/usr/local/bin/arm-none-eabi-size

As Gustavo suggested I ran with the flag (note its check-cxx - not check-gxx)

./modules/waf/waf-light configure --board px4-v2 --check-cxx-compiler g++
./modules/waf/waf-light build --target bin/arducopter-quad

and success it worked! Thanks!

@Bill is your waf working yet?

1 Like

Haven’t tried yet, been too busy… But I’ll try again soon

@guludo can we change the order so gcc is always the first one?

lucasdemarchi http://discuss.ardupilot.org/users/lucasdemarchi
August 18

@guludo http://discuss.ardupilot.org/users/guludo can we change the
order so gcc is always the first one?

Yep. That should be easy.

Yep, s,--check-gxx-compiler,--check-cxx-compiler, :slight_smile:

This works, thanks :slight_smile:

configure works, build fails

@billb could you please share the output of the px4_msg_gen target

I would if I knew what it was, I have no idea about waf or where it puts build files… it’s all new, so some hand holding helps, I learn fast :wink:

Works fine for me for both px4-v2 and px4-v4 targets. Maybe try a fresh clone of the source tree and submodules?

with a clean build it works, but with my current repo This is the error I’m getting. Maybe you can improve the script somehow. The other thing. What’s the bets docs to get a user guid to was builds so we can understand the build better? was is new to me, so I need a quick start guide so I can at least figure out how to diagnose some of the issues.

I really just don’t like blasting the repo as first course of action, since there always some wip in a branch happening. (or historical stuff i’ve fiddled with in the past and maybe useful stuff to me )

bonney@MacVan:ardupilot (master)$ waf build --target bin/arducopter-quad Waf: Entering directory/Users/bonney/dev_src/ardupilot/build/px4-v2’
[13/14] CMake Build px4 msg_gen
[ 0%] Built target git_gencpp
[ 0%] Built target git_genmsg
[100%] Built target msg_gen
[14/14] CMake Build px4 prebuild_targets
[ 0%] Built target __nuttx_patch_px4fmu-v2
[ 0%] Generating nuttx_copy_px4fmu-v2.stamp
cp: cannot overwrite directory /Users/bonney/dev_src/ardupilot/build/px4-v2/modules/PX4Firmware/px4fmu-v2/NuttX/./nuttx/arch/arm/include/board with non-directory /Users/bonney/dev_src/ardupilot/modules/PX4NuttX/./nuttx/arch/arm/include/board
cp: symlink: /Users/bonney/dev_src/ardupilot/modules/PX4NuttX/nuttx/configs/px4io-v2/src: File exists
cp: cannot overwrite directory /Users/bonney/dev_src/ardupilot/build/px4-v2/modules/PX4Firmware/px4fmu-v2/NuttX/./nuttx/arch/arm/src/chip with non-directory /Users/bonney/dev_src/ardupilot/modules/PX4NuttX/./nuttx/arch/arm/src/chip
cp: cannot overwrite directory /Users/bonney/dev_src/ardupilot/build/px4-v2/modules/PX4Firmware/px4fmu-v2/NuttX/./nuttx/include/apps with non-directory /Users/bonney/dev_src/ardupilot/modules/PX4NuttX/./nuttx/include/apps
cp: cannot overwrite directory /Users/bonney/dev_src/ardupilot/build/px4-v2/modules/PX4Firmware/px4fmu-v2/NuttX/./nuttx/include/arch with non-directory /Users/bonney/dev_src/ardupilot/modules/PX4NuttX/./nuttx/include/arch
make[3]: *** [nuttx_copy_px4fmu-v2.stamp] Error 1
make[2]: *** [CMakeFiles/__nuttx_copy_px4fmu-v2.dir/all] Error 2
make[1]: *** [CMakeFiles/prebuild_targets.dir/rule] Error 2
make: *** [prebuild_targets] Error 2

Waf: Leaving directory /Users/bonney/dev_src/ardupilot/build/px4-v2' Build failed -> task in 'px4_prebuild_targets' failed (exit status 2): {task 4581333264: cmake_build_task -> } ['/usr/local/bin/cmake', '--build', '/Users/bonney/dev_src/ardupilot/build/px4-v2/modules/PX4Firmware', '--target', 'prebuild_targets']

I would try:

waf distclean git submodule deinit -f .

Then try to build again.

Docs specific to ArduPilot are at: https://github.com/ArduPilot/ardupilot/blob/master/BUILD.md Like it says there, if you want to learn more about Waf you can read the book.

1 Like

you should add a link the the developer wiki http://ardupilot.org/dev/docs/building-the-code.html

Thanks for info :slight_smile: i try it later

@OXINARF That worked thanks

The intention was to update the docs there. However we have too many scattered info about building in the site… We decided to go with a clean approach in the repo instead.

It’s ok being it github but a link from the wiki to the page would really help.

Can we put all of this into a script like we have for Ubuntu? That script works great!

In master branch you don’t need this option anymore. The following should just do the right thing:

./waf configure --board px4-v2
./waf --targets bin/arducopter-quad

I think you fixed that issue of compiler, but now master doesn’t build… :wink:

see Master@59366b0 fails to build

LATER: you need to install pip install lxml future

I didn’t break it. They are new requirements from pymavlink