Problem with build/compile instructions (in Ubuntu)

@dipspb I can have 2Gb in an instant because I am using Ubuntu in the cloud, even if cloud memory is $11/month/Gb !

Ok. Will try to do it with 512 Mb RAM. Is your Ubuntu 32bit vs 64bit (i386 vs amd64 image) ?
Can you re-install ubuntu from scratch to have clean image?

@dipspb Ubuntu 14.04 64bit , which can be reinstalled from scratch in 120 seconds on my Ubuntu in the cloud. I can also have 32 bit ubuntu …easy cloud ubuntu.

Here is solution that will not require to extend RAM of your ubuntu server. I checked it and it works on ubuntu-14.04.4-server-amd64 with 512Mb RAM like a charm:

  1. reinstall your ubuntu server from scratch
  2. ssh into your ubuntu server and then run commands below one-by-one
  3. wget https://raw.githubusercontent.com/dipspb/ardupilot/Copter-3.4-init-tools-script/Tools/vagrant/init-tools.sh
  4. chmod a+x ./init-tools.sh
  5. sudo ./init-tools.sh
  6. source $HOME/.profile
  7. git clone https://github.com/ArduPilot/ardupilot.git
  8. cd ardupilot
  9. git checkout Copter-3.4 ; git submodule sync ; git submodule update --init --recursive
  10. cd ArduCopter
  11. make clean ; make px4-v2
  12. *ls -l .px4

Initially I intended to use original script from here SITL Vagrant tool set https://github.com/ArduPilot/ardupilot/blob/Copter-3.4/Tools/vagrant/initvagrant.sh
but it seems there are some issues with packages needed to build 3.4 on ubuntu 14.04.
So I reworked it and created my own. It will not provide you SITL features, just ability to
build the image.

Hope it helps. Let me know in case you will have problems with it.

Later I will describe how to compile it w/o installing any toolchain on your OS. It will require a computer that is capable to run VirtualBox and Vagrant, it needs I believe 3Gb RAM at least (haven’t checked it against 2Gb RAM) and probably a GUI.

@maxmay as pointed out in your other thread:
http://discuss.ardupilot.org/t/is-make-compile-different-from-copter-3-3/12421/5

Start with these instructions:
http://ardupilot.org/dev/docs/building-px4-for-linux-with-make.html
3.4 uses waf, so for the build steps, follow this:

It’s very straight forward, if you get any problems just post the errors here and we can help you.

It is definitely not so much straightforward as it declared. Here is my attempt on brand new just installed ubuntu-14.04.4-server-amd64 with 512Mb RAM:

dipspb@ubt1404srv512:~$ sudo apt-get update
.
.
.
dipspb@ubt1404srv512:~$ sudo apt-get -y install git
.
.
.
dipspb@ubt1404srv512:~$ git clone https://github.com/ArduPilot/ardupilot.git
dipspb@ubt1404srv512:~$ cd ardupilot/
dipspb@ubt1404srv512:~/ardupilot$ git checkout Copter-3.4
Branch Copter-3.4 set up to track remote branch Copter-3.4 from origin.
Switched to a new branch 'Copter-3.4'
dipspb@ubt1404srv512:~/ardupilot$ 
dipspb@ubt1404srv512:~/ardupilot$ # === Not sure waf will synchronize git submodules so doing by hands
dipspb@ubt1404srv512:~/ardupilot$ git submodule sync
dipspb@ubt1404srv512:~/ardupilot$ git submodule update --init --recursive
.
.
.
dipspb@ubt1404srv512:~/ardupilot$ ./waf configure --board px4-v2
Setting top to                           : /home/dipspb/ardupilot 
Setting out to                           : /home/dipspb/ardupilot/build 
Autoconfiguration                        : enabled 
Setting board to                         : px4-v2 
Checking for program 'arm-none-eabi-ar'  : not found
Could not find the program ['arm-none-eabi-ar']
(complete log in /home/dipspb/ardupilot/build/config.log)
dipspb@ubt1404srv512:~/ardupilot$ # === Umm.. shouldn't it install everything needed?
dipspb@ubt1404srv512:~/ardupilot$ # === Nevermind, let's give it a try.
dipspb@ubt1404srv512:~/ardupilot$ ./waf copter
The project was not configured: run "waf configure" first!
dipspb@ubt1404srv512:~/ardupilot$ # === NO LUCK!

It seems it requires a toolchain to be installed first, but so far I can see the toolchain issue was initial problem of @maxmay .

So link to the waf document cannot be considered as a solution for him, because waf document doesn’t have even a mention on toolchain installation requirements or steps. Instead it makes impression that everything is automated and waf will take care on toolchain by itself.

I’m sorry so much, but it couldn’t be referred as working solution yet. Probably due to documentation issue.

regards,
Dmitry Prokhorov

@dipspb , read carefully ! http://ardupilot.org/dev/docs/building-px4-for-linux-with-make.html#setup !!
You miss an important step that install everything on your computer for compiling ! ( Tools/scripts/install-prereqs-ubuntu.sh -y)

For information, waf install nothing. Doing waf configure only check if all dependencies are present and prepare the build.
On your try, you try to build for px4-v2 that use arm-none-eabi GCC compiler.
You can see that your first error is Checking for program ‘arm-none-eabi-ar’ : not found
Could not find the program [‘arm-none-eabi-ar’] . So you are missing the compiler ! (and probably many other dependencies !)

Give another try by reading carefully step by step and you can get rid of vagrant ^^

@dipspb ok I will try this , but does it first require a computer that is capable to run VirtualBox and Vagrant ?

Thank you for your point, but…

Isn’t it a confusing that toolchain installation step is described on a page “Building ArduPilot for Pixhawk/PX4 on Linux with Make what is recommended to don’t follow for 3.4 on page “Building the code” ?!

Code building has changed for newer releases to use waf build tools, replacing make

I can see it reported a lack of arm GCC compiler, it was exactly my point.

Vagrant is used to run SITL and it is good tool to use it for build on any compatible platform. It makes it possible to don’t install bunch of tools and libraries on your OS just to build the image. Moreover it avoids potential conflicts among installed tools/libraries versions at the moment you will need to install more recent versions as soon as new ardupilot release will be available. I definitely sure, Vagrant worth to be considered as a good, not an evil.

Instructions I provided you so far not require to use Vagrant and VirtualBox. Just try them as it is.

@dipspb - I think you’re confused about the terminology around toolchain, dependencies and make. The line that you quote has to be taken in context, the next line says:

In most cases the build dependecies described for make are the same, the only part of the instructions changes is the issue of the waf build commmand.

waf isn’t some magical command that sprinkles fairy dust and does everything for you, it’s just a replacement for make. You cannot compile something without a compiler toolchain, which involves installing dependencies. So the instructions remain the same, except that you replace the make command with the waf commands.

Questions and process like this is really useful for the community as it gives everyone a chance to clarify and improve the build or documentation if it needs it.

@dipspb - I would recommend that you follow the official docs and post any problems you have, and we’ll do our best to help you. They should work, and they are straight forward.

Thank you for pointing it. This story is not about me. I able to compile all needed tools from sources w/o any package manager used, no problem. I just described how it may looks like for inexperienced user like @maxmay. I believe it’s not a big problem to refer to mentioned Tools/scripts/install-prereqs-ubuntu.sh script on waf page.

Just attempted to follow in exact way all steps using waf and prerequisites as they documented. Still have no success:

dipspb@ubt1404srv512:~$ sudo apt-get update ; sudo apt-get install -y git
.
.
.
dipspb@ubt1404srv512:~$ git clone https://github.com/ArduPilot/ardupilot.git
.
.
.
dipspb@ubt1404srv512:~$ cd ardupilot/
dipspb@ubt1404srv512:~/ardupilot$ git checkout Copter-3.4
Branch Copter-3.4 set up to track remote branch Copter-3.4 from origin.
Switched to a new branch 'Copter-3.4'
dipspb@ubt1404srv512:~/ardupilot$ Tools/scripts/install-prereqs-ubuntu.sh -y
.
.
.
dipspb@ubt1404srv512:~/ardupilot$ . ~/.profile
dipspb@ubt1404srv512:~/ardupilot$ ./waf configure --board px4-v2
Setting top to                           : /home/dipspb/ardupilot 
Setting out to                           : /home/dipspb/ardupilot/build 
Autoconfiguration                        : enabled 
Setting board to                         : px4-v2 
Checking for program 'arm-none-eabi-ar'  : /opt/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-ar 
Using toolchain                          : arm-none-eabi 
Checking for 'g++' (C++ compiler)        : /opt/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-g++ 
Checking for 'gcc' (C compiler)          : /opt/gcc-arm-none-eabi-4_9-2015q3/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'                   : not found 
Could not find the program ['cmake']
(complete log in /home/dipspb/ardupilot/build/config.log)
dipspb@ubt1404srv512:~/ardupilot$ ./waf copter
The project was not configured: run "waf configure" first!
dipspb@ubt1404srv512:~/ardupilot$ 

It would be nice to know what exactly I missed and where missed step is documented.

cmake install is missing from the install-prereqs-ubuntu.sh script. I note that the compiler is a slightly different version from that documented, so it’s probably worth opening a github issue and getting the docs/script updated. Here’s the commands that work on a fresh ubuntu VM for me:

sudo apt-get -qq -y install git
git clone https://github.com/ArduPilot/ardupilot.git
cd ardupilot
git submodule init
git submodule update
Tools/scripts/install-prereqs-ubuntu.sh -y
sudo apt-get install cmake
. ~/.profile
./waf configure --board px4-v2
./waf copter

This is exactly as documented, except for the missing cmake dependency.

Thank you, I know. But one more time, it’s not about me… Of course I will submit the issue.

Are still sure instructions are ok?

@maxmay I believe you need to follow recent instructions provided by @fnoop as a most correct approach for this moment.

@dipspb - if you have some ideas to improve the build system, make it more generic or easier for beginners etc, why don’t you chat with the developers on gitter or post in the Development forum? I’ve only had a couple of small interactions with the devs but they’re super nice and friendly, and really keen to help new people who want to get involved. They answered my basic and stupid questions and helped me out to submit a small 3 line patch when it would have been much quicker to do it themselves.

@dipspb @fnoop thank you both for the help identifying the issue. Both provided valuable feedback. I just submitted a PR to add the missing dependency: https://github.com/ArduPilot/ardupilot/pull/5106. This will be backported to 3.4.1.

In future we will need to streamline our scripts to install dependencies so this kind of issue doesn’t happen anymore.

@maxmay I hope the instructions they provided are enough.

@dipspb @fnoop @lucasdemarchi …I will try the last fnoop instructions, and give results here, and if it works I will contribute $ to ardupilot.org as promised.