[SOLVED] How to Compile the Code

Hello,

So there may be a very simple answer, but I have seen the C++ files that make the .deb on the Github link, but I do not know how to compile everything together to create the .deb file from the files on Github. I am looking to experiment with the code, so if anyone can help or point me to some set of instructions, please let me know.

Thank you!

hello

You tried code example?

in each, for example:
a makefile file is, when you write make + enter,

making that file is to write to the terminal

g ++ -I you_script.cpp library.cpp, or you_script

if your code is error you_script creates a file which runs on the Linux terminal ./you_script

I recommend you visit these links.

https://courses.cs.washington.edu/courses/cse326/02wi/unix/g++.html
http://iie.fing.edu.uy/~vagonbar/gcc-make/gcc.htm

Thank you!

The second link is in Spanish so I can’t read it. But other than the issue of makefiles, at what point does the actual .deb get created?

Do you really want to create a .deb file or do you want to compile APM elf binaries from the source?

I guess I do not really know the difference. I want to edit the APM and put it on the pi. When you download the APM the site gives you, it gives a .deb file, so I assumed that I needed to create a new file of the same type, but with my edited code files used to make it.

Ok I looked at it more. I don’t need to recreate the whole .deb, I just want to recreate the specific binary file(s) that I will need from edited source cpp files.

Check out http://docs.emlid.com/navio/Navio-APM/building-from-sources/

Download the APM’s port for Navio:

git clone https://github.com/emlid/ardupilot.git
For Navio and Navio+ boards switch to the ‘navio’ branch:

git checkout navio
For Navio Raw switch to the ‘navio-raw’ branch:

cd ardupilot/ArduCopter
make configure
make navio

When I try to follow these instructions on my pi, it fails. It says

…/mk/build_rules.mk:11: recipe for target ‘/tmp/ArduCopter.build/control_rtl.o’ failed
make: *** [/tmp/ArduCopter.build/control_rtl.o] Error 1

If you have a linux pc around, try to follow the crosscompile instructions in the docs.
They work and crosscompilung is much faster.
If you try to compile on a Rpi2, you will have to install a new version of gcc. It is desccribed in this thead:

On Wheezy I have successfully compiled apm, you do need to upgrade gcc as suggested by @schuermannsebastian. On Jessy, it will compile fine, no gcc upgrade required, but you will need to apply the RT patch yourself and disable FIQ. Wheezy will be easier for now until a proper Jessy image is provided.

In either case, you will need to read up a bit more on Linux compilation, etc, which most answers can be found via google.

I did everything there, but I do not know where the .mk file that he talks about is.

I’m sorry but I wasn’t quite sure what some of this meant. I updated gcc but the latter part of the provided thread (discussing the change in the “…tools.mk” file) I was unable to do because I could not find the /mk directory.

The following part is also something that I am not yet familiar with

but you will need to apply the RT patch yourself and disable FIQ.

I actually did do the cross-compile on Linux, sent it to my Pi, and when I try to run the APM with the sudo ArduCopter-quad -A udp:… line, it says ArduCopter-quad is not a found command. I even tried it without the “-quad” since the .elf is named without the “-quad”, and neither command can be found.

Try

sudo ./ArduCopter.elf -A udp:GCSIP

I do not believe I have seen this before. Is this part of old instructions?

What does the “GCSIP” mean?

And it said “Raspberry Pi 2 with BCM2709!” (x2) then “Interrupted”

It’s means the ground control station’s IP address…

Ah… clearly wasn’t really looking at that one very closely.

Now instead it says
"PANIC: failed to take _bus->sem 100 times in a row, in AP_Compass_AK8963"

Try starting again, sometimes initialisation fails on the compass, maybe someone from Emlid can comment further as to the cause.

Restarting it didn’t help… Just got the same result.

Ok so I tried to build the code directly on the Pi, and then someone gave me instructions on how to use gcc on the Pi. And then part of the instructions weren’t possible for me to do since there was a file missing. I was told to use a different github, which seemed to me like it wouldn’t match up. Then I just decided to build on linux because that was what was suggested. And now it can’t connect to the GCS for various failures. Has anyone else specifically build the code themselves to tell me that it really has been working with any of the updates that may have happened more recently?

The ONLY THING that I can think that may be different: I am unable to navigate to the navio branch of the github until I cd into the ArduCopter folder, then it works, but this is different than the order of operations listed in the instructions.