Setting up a C/C++ Cross-Development Platform
This video introduces C and C++ programming on the Beaglebone platform, which is applicable to any embedded Linux development. I quickly introduce how we can program directly on the beaglebone using a terminal window and point out the limitations. I show the steps that are necessary to set up the Eclipse CDT environment and use the Target Management RSE (Remote System Environment) plugin to communicate with the Beaglebone. I then demonstrate how we can use Eclipse CDT IDE to cross-develop (using arm-linux-gnueabi) applications for the ARM architecture. To do this, I write a short program that flashes the user LEDs on the Beaglebone. Finally, I demonstrate how we can set up a cross-debug environment, where we use gdbserver on the arm device and gdb-multiarch on the client device to establish a full debug environment.
Video 1 – C and C++ programming on the Beaglebone platform
One common problem that arises with this setup:
If bash reports “file not found” when executing an executable file that exists, the reason is that it doesn’t recognise it as a binary file, and attempts to treat it as a script. The hypothetical script should start off with #!/path/to/interpreter and bash cannot find the (non-existent) interpreter so it returns “file not found”. This could happen if for example you are running a 64-bit executable on 32-bit machine, or an x86 executable on an ARM target.
In Eclipse your executable should display in your source directory as “HelloWorld – [arm/le]” in the project explorer window. If it does *not* then there is a problem with your compiler setup and you need to watch the steps again. If it *does* then one likely problem is if that you are using an ARM Linux platform that uses “hard floats” and that you have compiled using my setup which uses “soft floats”. Here are two possible solutions:
– Graemefisheratwork let me know that he has found that when using the ubuntu armhf distros, applications should be cross-compiled using arm-linux-gnueabihf- and not arm-linux-gnueabi-. This seems to have worked for him on the ubuntu 12.04 armhf build.
– I’m using “Linux omap 3.2.18-psp14 armv71″ in this video that I built myself which has defaulted to soft floating point numbers. There are floating-point options in gcc that you have to set when using hardware floating point numbers — you should add ” -mfloat-abi=hard” to your compiler options.
LOVE your new site Derek, and of course all your video tutorials. So much appreciated! I’ll definitely be following the site, as I need to start working with the ‘bone again.
Thanks for all the efforts.
TB
Great video! The presenter demonstrates how to setup your development environment, at the right speed, without boring you.
Thank you very much for producing and sharing this video!
-ED
I started investigating beaglebone last week after “toying” with arduino for the last couple of months. In the real world (where I make a living) I do most things in eclipse (C++, Perl, PHP, JavaScript). In the toy world I am forced to work in arduino’s very limited sketch IDE after finding arduino’s plugin into Visual studio and Atmel does not support the latest arduino libraries. Also, the memory, CPU limitations and wifi module exhoberant pricetag ($120) has soured my toy experience. Your video has convinced me to take the plunge into robot development and stop playing with toys 😉 Thanks!
In Eclipse Kepler (and maybe earlier versions?) you can use Automatic Remote Launch to remotely debug automatically. Do everything here: beagle bone http://wiki.eclipse.org/CDT/User/FAQ#How_do_I_debug_a_remote_application.3F except replace gdb by gdb-multiarch under the Debugger tab
Can this be done in windows ?
Yes, but it is not straightforward when it comes to the cross compiler.
Hello Derek,
Thank you for the the excellent videos, I have greatly benefited from your contributions. As mentioned by Ted. I had to reference http://wiki.eclipse.org/CDT/User/FAQ#How_do_I_debug_a_remote_application.3F to get remote. debugging working. What you have described is “Manual Remote Launch” which is one of three options? Mentioning this on the video might greatly help the viewer.
Thanks again
Great video Derek, Thanks.
I ended up switching to the Kepler release of eclipse as well. Turns out Kepler also has a tool chain called “Cross GCC” that manages include and lib paths for different target types.
First off, thank you for the instructions. They are very welcome.
I’m a complete eclipse newbe, so please bear with me. However, when doing this install exactly like you (to the letter), my Eclipse does NOT show the Remote Systems directory with the freshly installed plugins. However, I DID installed them and extracted them into the .eclipse/org..yadda yadda/plugins and features directory respectively (and tripple checked they are there).
Anyone any idea why this is and how I could fix it? I’m keen on writing my first C programs for the BeableBoneBlack…
TIA
Markus
Ok, I could solve the problem by completely uninstalling eclipse and re-installing it thereafter. I must have made some mistake along the way. Now everything I want works like a charm. Thank you!
On a side note, if you start up gdbserver on the beaglebone, it’s possibel to start it as gdbserver :12345 executeable, that said to omit the PCs IP adress. If done so, gdbserver accepts any PC connecing to it. Of course only an option in a trusted envireonment.
I’m a very happy camper now.
BR,
Markus
I assume Derek’s suggestion on working with 64-bists platforms is right. I could compile the Hello World program on a 64bit Linus Mint System with Eclipse Kepler. That, and other programs functioned on my Beaglebone, but I was not able to remote debug the programs. When I switched to Ubuntu 32 bit on my desktop computer everything, remote debugging included, worked flawlessness. Differences with Derek’s suggestions: Angstrom on the Beaglebone and I installed the remote access in Eclipse 3.7.2 by loading the Eclipse plugin (Remote System Explorer: In the Eclipse menu: install new software.) Maybe it’s a new feature, easier to install than the way of the video.
Derek thanks!
Dear Professor Malloy
Thanks again for your wonderful videos. I also ran afoul of the -hf problem, and also changing the compiler, etc., solved that issue, it cause grief when doing the debugging.
I suspect I had a lot of trouble because I was usuing a completely clean ubuntu installation on the PC and as a result some things which other people were fortuneate to avoid, I stepped directly in to. Nevertheless, over several days and with the help of the google beaglebone forum I was able to get things working.
The key issue for me was the selection of debugger: I had to use linaro gcc-arm-linux-gnueabihf-gdb or I would get a protection fault on the BBB.
I went back and more or less transcribed my results and posted that transcription to the google beagleboard forum with this stupidly long url
https://groups.google.com/forum/embed/?place=forum/beagleboard&showsearch=true&showpopout=true&showtabs=true&hideforumtitle=true&parenturl=http://beagleboard.org/Community/Forums&afterlogin#!category-topic/beagleboard/support/newbies/beaglebone-black/software/ubuntu/g4oSArTk2Cw
I figured if I did that it would be searchable, etc..
I want to thank you again for your great work
Brian Piccioni
Dear Professor Malloy
I spent a few days figuring out how to avoid manually copying the file and invoking ‘sudo gdberver 192.168 ….
This greatly speeds things up and reduces frustration due to typos. Here is my solution (comments are //)
//On the target system (BBB) find out where your gdbserver program is
whereis gdbserver
// in my case it is in /usr/bin/gdbserver
// edit the sudoers file
sudo visudo
//Add the following line to the end of the sudoers file (where myusername is brian in my case)
myusername ALL=NOPASSWD:/usr/bin/gdbserver
//exit [^x] and save
//create a script file which invokes gdbserver as sudo
sudo nano /usr/local/bin/sudogdbserver
//type these lines into the editor
#!/bin/bash
#make gdbserver act as sudoed (set gdbserver as NOPASSWD in sodoers)
sudo gdbserver $1 $2
exit
//exit [^x] and save
// make the script executeable (and read/write for good measure)
sudo chmod +rwx /usr/local/bin/sudogdbserver
//
// you might want to test the script, just for laughs
sudogdbserver 192.168.0.14:2345 helloworld
//
// Now, in eclipse,
// set [RUN][DEBUG CONFIGURATIONS] [MAIN] Using GDD (DSF) Automatic Remote Debugging Launcher,
// make sure your remote absolute file path points to your executeable (or it’ll be copied to the wrong place)
// and select Tab Debugger in Tab Gdbserver settings enter sudogdbserver in Gdbserver name.
//
// Now when you debug programs using file IO you don’t have to manually copy and invoke sudo gdbserver
//
I hope this is of use to users.
Thanks again and keep up the good work!
Brian Piccioni
Hi Derek,
A question……………..
Why install Virtualbox and Ubuntu for cross development? Why not install Eclipse native in Windows and install a native SSH client?
(I have installed Virtualbox and Ubuntu but it is dog slow at doing anything and the screen resolution is poor)
Ray
Great explanation. As a newbie to just about everything touched on here, it took me a while to get through a few details. A few notes on my mistakes may help others get started.
When installing Ubuntu workstation under VirtualBox, select Bridged Adapter instead of the default NAT. This assumes you have a firewall router in front of your cable modem. This will allow the remote debugging session part of the video to make sense since your Beaglebone Black (BBB) ip address and your virtual Ubuntu workstation will appear to be on the same subnet. (tip: ifconfig and arp-scan help to see what is addresses are getting assigned. Verifying communication with ping is also good to know.)
After installing Ubuntu, apt-get install build-essential. Somewhere along the way I had to select to Show Hidden Files for them to appear in a console with ls -la. Looking back at the system now, its not so clear, except perhaps the first time you select from the Ubuntu View menu to Show Hidden Files this may have some lasting effect on future Terminal console’s interpretation of ls -la.
Add to the Include paths a second path to /bits. The referenced files reference this subdirectory too.
Find and use the Eclipse Reindex function often. Most of the problems with ‘unresolved’ resources or ‘not found’ functions can be resolved by “Index–>Reindex” or “Index–>Update with modified Files”. In the Project Window (Window–>Show View–>C/C++ Projects), right click the project name (e.g. “HelloworldTest”) and select “Index”.
If you want your (BBB) to have a fixed ip address, simply create an interfaces file in /etc/network.
Thanks. I didn’t get any relief using index>Update with modified files, but index>reindex did the trick.
Hi Derek,
Thanks a lot for the useful tutorial. I followed it quite closely and managed to compile “hello world” on beagleboane black and cross compile it on Virtual Ubuntu. I got both executable files to output the same string but their size is considerably different.
$du hello_world.o HelloWorldTest
12 hello_world.o
72 HelloWorldTest
any idea why and how to fix this?
-Alex
Hello Sir,
I am using beableboneblack.I have learnt so much from your videos regarding bbb. But i am unable to find tutorials for C/C++ programming for Beable bone boards on internet. So please suggest any books or material or give me some useful links……
Thanks, greate kickstart. I can confirm that arm-linux-gnueabihf is required for ubuntu. I used the Kepler version of eclipse.
In C++ 4.7.3, the line char *LEDBrightness = “sys/class/leds/beaglebone::usr3/brightness”; has two problems. The latest BBB uses “sys/class/leds/beaglebone:green:usr3/brightness”.
Secondly, the way you can compile without getting a warning is to change to:
char LEDBrightness[] = “sys/class/leds/beaglebone:green:usr3/brightness”;
Vinod: look at Derek Molloy’s other tutorials. derekmolloy.ie
Arnie: I was able to follow the above tutorial using arm-linux-gnueabi using eclipse 3.8.
Great tutorial. Many thanks.
I attempted to compile the files from github and got an error. It chokes on sleep, which is not defined. Where did you get it?
g++ TestApplication.cpp -o TestApplication
returns:
“TestApplication.cpp: In function ‘void StepperMotorTest()’:
TestApplication.cpp:57:9: error: ‘sleep’ was not declared in this scope.”
I have done C++ and Assembly on linux and am aware that functions must be declared before use.
I just don’t see how it is declared in this project.
Thank you!
Hi Charles,
unistd.h was implicitly included on the IDE. I have fixed the code to include it explicitly and I have added a build script. Please be aware that this code is out of date with the more recent versions of Linux that use the device tree model. I haven’t had the chance to update it yet.
Have a look at my work at: http://derekmolloy.ie/beaglebone/beaglebone-gpio-programming-on-arm-embedded-linux/ where the top video explains the changes that have taken place on more recent versions of Linux.
Kind regards, Derek.
Hello sir,
I am a student. I need to use BeagleBone Black in a robotic competition. So far, I’m still deciding whether to use C/C++ or node (bonescript). I have quite firm basics in C/C++ but none on node. Your tutorial convince me on using C/C++.
However, there’s one last doubt in my mind. Can a BBB (running ubuntu) be able to run a C/C++ script automatically on boot with root permission? The root permission is for using the GPIO. I need my robot to be able to operate as soon as it boots up, without needing me to run the script manually first.
Thank you sir. And such a lovely and good tutorial, looking forward for more 😉
Yes, if you set the permissions carefully you can use rc.local to execute a program/script on boot just like you would under Ubuntu client/server. On Angstrom you can use systemd and remember that you have cron if you wish to run something at regular intervals.
I’m teaching embedded systems to undergraduates at Plymouth University (UK).
I really appreciate the videos Derek has taken the time to create. Many of the comments from others have proven really helpful as well. it’s very much appreciated.
For my own students, I’ve now created another video which I hope consolidates some of the above. The resulting setup gives a very seamless build, deploy and debug workflow from within Eclipse.
I’ve uploaded the video on YouTube in case it’s of use:
http://www.youtube.com/watch?v=z0AB8WZY5HY
I am still struggling with one issue however – on Angström, I get errors if I try and use shared libraries. I believe the reason is that the cross dynamic loader in my cross development tools (from the Ubuntu 12.04 repository) is different to the that on the Angström image. Not yet sure how to best fix this.
Another issue is floating point support with Angström. The Ubuntu image requires the hard-float libraries. Does anyone know if I need to do anything special to get hardware floating point when targeting Angström?
Thanks Nick.
Great to hear that the videos are useful for modules in other universities. I’m not sure about the problems with the cross dynamic loader, but on the hard floats:
– when using the Ubuntu armhf distributions, applications could be cross-compiled using arm-linux-gnueabihf- and not arm-linux-gnueabi-. This seems to have worked for a good few people on the ubuntu 12.04 armhf build.
– you could also try adding ” -mfloat-abi=hard” to your compiler options.
Hopefully that works for you,
Derek.
Great tutorial, had some minor problems but that was due to my lack of Linux.experience.
Running VirtualBox host: WIndows 8 64-bit and client: Ubuntu 12.04LTS talking to a Beaglebone Black.
Article was instrumental in setting up my development environment and getting started with programming the BBB.
Very good tutorial thanks,
Mike
Thank you.
When using Angstrom on the beaglebone and trying to connect with Eclipse RSE I get. Daemon failed to launch server on 192… using port 0.
I can launch a local shell on Eclipse and ssh into the board from that. So it appears it is a dependency on the bone that is fulfilled under Ubuntu in your example but not fulfilled under Angstrom.
If I find a solution for this I will post it. If anyone else has encountered and solved the same please let me know.
I am having the same issue, have you found a solution?
I followed the instrctions in the video.But I got an error”make:***[src/HelloWorldTest.o] Error 127, symbol cout could not be resolved”.Can anyone tell me where am I wrong.
**** Build of configuration Debug for project HelloWorldTest ****
make all
Building file: ../src/HelloWorldTest.cpp
Invoking: GCC C++ Compiler
arm-linux-gnueabi-g++ -I/usr/arm-linux-gnueabi/include/c++/4.6.3 -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF”src/HelloWorldTest.d” -MT”src/HelloWorldTest.d” -o “src/HelloWorldTest.o” “../src/HelloWorldTest.cpp”
/bin/sh: 1: arm-linux-gnueabi-g++: not found
make: *** [src/HelloWorldTest.o] Error 127
**** Build Finished ****
How can I add the arm-linux-gnueabi-g++ to the path? And I have installed GCC ARM and G++ ARM.
I am having this same problem. Did anyone find a solution?
I am having this same problem. Did anyone find a solution?
Edit: This was happening because I only installed g++ on the beagle board, but not on the machine with eclipse. To fix this problem if you are using Ubuntu, open a terminal and type sudo apt-get install g++. delete the broken eclipse project and create a new one and the fix will take effect automatically.
Thank you very much David, great site and tutorials.
Derek,
Your videos have REALLY helped me get started with the BBB. Many, many thanks for taking what must have been a lot of time making such high quality videos!
But I’m having trouble reproducing your gdbserver steps on the BBB…
I’m running a Ubuntu 12.04 (precise) image on my BBB that I got here: http://www.armhf.com/index.php/download/. I changed to Ubuntu because I had no luck cross compiling for Angstrom, and it seems that the Angstrom distro webserver has been down for a long time – not exactly confidence inspiring… So I abandoned what looks like a sinking Angstrom ship and boarded Ubuntu. So far, the change has been great.
My BBB is connected to my LAN with a static IP, and has internet and nameserver access (I use google’s nameservers). Pinging any domain name from the BBB works fine, so I assume it would have access to new packages. However, when I log in to the BBB as root and run “apt-get install gdbserver”, apt-get returns a message saying it cannot find the gdbserver package. The /etc/apt/sources.list file on the BBB looks reasonable to me. What am I doing wrong?
BTW, I’ve been able to cross-compile for ubuntu 12.04 on the BBB using the Linero 4.8 toolchains with Eclipse Kepler running on both Virtualbox/ubuntu 12.04, and with Eclipse Kepler running native on my Windows XP laptop. The Linero 4.8 toolchain for Windows seems to work fine running Eclipse native on Windows XP following the exact same Eclipse setup that you show in your video for your Virtualbox/Ubuntu/Eclipse system. There is also a nice Eclipse plugin for doing gnu-arm cross compiling here: http://gnuarmeclipse.sourceforge.net ,but I find that following your instructions for setting up the Eclipse environment more satisfying because doing so has less of a “black box” feel.
Thanks again for sharing your knowledge!
I had this same problem, but it was easily fixed by running sudo apt-get update
Where do I sign up for the Derek Molloy fanclub? Your videos are amazing! As a newbie, I appreciate the clear and simple instructions. Cheers!
Hello Derek,
I appreciate your videos are very helpful in setting up the development environment using the open source software tools. I have one query when setting up the debug environment for the BBB, since the FTDI 3V3 cable is used for debugging the BBB , what can be configurations in the eclipse and on the BBB?? I tried to use the generic serial protocol but failed!!!!
Any suggestions will be of great help!!!!
Regards,
Gibson
Hello Sir, when i issue command sudo apt-get install gcc-4.7-arm-linux-gnueabi on ubuntu 13.10,
it says
Reading package lists… Done
Building dependency tree
Reading state information… Done
Note, selecting ‘gcc-4.7-arm-linux-gnueabihf-base’ for regex ‘gcc-4.7-arm-linux-gnueabi’
Note, selecting ‘gcc-4.7-arm-linux-gnueabi-base’ for regex ‘gcc-4.7-arm-linux-gnueabi’
0 upgraded, 0 newly installed, 0 to remove and 26 not upgraded.
but is not installing. Can u help me with the problem
Thank you for the tutorial. I am having trouble with the debugging portion of the video. At 36:10 in the video, when I am trying to SSH into the BeagleBone, it is asking for a password for the BB. Any password I try will not work.
I am logging in as root, and it is not working. Even when I try to log in as my Ubuntu username, it is not accepting my password. I have done everything so far on root, and it has worked well.
I believe this is the last thing I need before debugging the BeagleBone.
Hello Derek,
your videos are very helpful to me.
I had one issue the last few hours:
First i apt-get the “gcc-arm-linux-gnueabi” and “g++-arm-linux-gnueabi”-packets. The result was the “no such file or directory”-message when i tried to start it in the terminal on my BBB.
After a few unsuccessful tests i decided to try the “…gnueabihf”-packets.
The upshot was that i got a warning from the linker: “warning ld-linux.so.3 needed by…” blabla.
I’ve got the solution here: http://www.claus.com.ar/2012/06/setting-up-eclipse-for-cc-development.html
I add a link between two files like mentioned above:
$sudo ln -s /usr/arm-linux-gnueabihf/lib/ld-linux-armhf.so.3 /usr/arm-linux-gnueabihf/lib/ld-linux.so.3
After that i didn’t get a warning from the linker.
Perhaps i can save hours for fellow sufferer.
Now it works and i got my “Hello World!” on my BBB…and i am absolutly impressed by this way of programming.
greets
knucklehead
Greets Derek,
Thank you for all these offerings and the effort that goes into them. Such an incredible resource for developing embedded systems, especially those that use numerous subsystems. Of all the research I have done, finding your work ranks up there next to discovering David Jones and his EEVBlog.
This may sound silly, but you should add “cross-compiling” to the tags for this tutorial. For those of us who are not Electrical Engineers, I.T. pros, and computer science majors. When I discovered the process, everything I read was “cross-compiling”. I never thought about “Cross-Development” or I would have discovered you, and this tutorial, much sooner.
Thank you again for what you are doing. You and your work is such an incredible resource!
Thanks Gary, good point.
Hello Derek,
I already set this type of thing up for cross-compiling for the Raspberry Pi in Eclipse Kepler running in 64-bit Debian Linux in a virtual machine (vmWare) on my Windows 7 64 bit laptop. It works wonderfully and I’m here because I want to do that with my BeagleBone Black.
So my question is, may I use the same cross-compiler for the BBB? After reading a comparison of the BBB and RPi, I found that the BBB uses the ARM v7 instruction set where the RPi uses ARM v6. I am assuming that matters and expecting to set up another cross-compiler within the same Eclipse. Can I expect any issues with this? I am afraid I will corrupt my RPi development environment and I spent considerable time setting that up. I suppose I could back up the virtual machine in case something does go wrong or set up another virtual machine for cross-compiling for the BBB. I would like to have all that under the same hood as the RPi though.
Thank you sir for the incredibly informative and extremely valuable resource you have put together for the public. I certainly appreciate it!!
Hi Gary, thanks. I haven’t set up cross-compilation for the Raspberry PI, but I don’t see a conflict there. If you are using the new Debian distribution for the BBB you can use the armhf development toolchain and I would imagine that it is the same for both platforms. Before you do anything, try building a “Hello World” application for your PI toolchain and transfer it to the BBB. The latest compiler for the BBB is g++-4.7-arm-linux-gnueabihf under the emdebian distribution. Derek
Thanks for all your wonderful information. I’ve set up a virtual machine to develop for BBB using Debian squeeze. I’ve added the emdebian repositories to apt, but have found that the gnueabihf toolchain isn’t there (just the regular gnueabi one, which doesn’t work for the BBB). Do I need my VM to use the emdebian distribution instead of Debian as is now set up? Is there a repository to add which would contain the hf toolchain for this distribution? I’d hate to have to set up another VM if it isn’t necessary. Thanks.
I believe I’ve answered my own question. A generic compiler (for any linux distribution) for the Beaglebone is available here:
http://eewiki.net/display/linuxonarm/BeagleBone#BeagleBone-ARMCrossCompiler:GCC
HI Derek,
I followed your great tutorial to the letter – and I am ALMOST there! But for some reason, when I open up a Hello World style template in Eclipse (as shown in the tutorial), I see some error icons just to the left of the lines of code. The iostream include does NOT show an error, but hovering the mouse over the lines containing std, cout and endl reports, ‘Symbol could not be resolved’. Please help! Much thanks.
Best regards,
Anthony Webber
Did you ever get this resolved? I’m seeing the exact same thing.
One thing I am missing… Where/how do I install the beaglebone libraries that are required on my local development environment – the /sys/class/leds/beaglebone…. etc
How do I get those installed locally?
Thanks,
Brian
When i try to start the hello world executable via the terminal i get this error:
“error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory”
my beagleboard black is a rev C running the included debian distribution.
Hello there,
I have the exact problem as Alex!
Same here. I’ve tried pretty much every possible combination of Library and LibraryPath settings in the Project > Properties > C/C++ General > Paths and Symbols > Libraries and Library Paths tabs. If I get things to build properly in Eclipse, it fails on the target BBB. If I set it up so that the linker in Eclipse can actually put the -l libstdc++.so in the build line, then it complains on the Eclipse console that it can’t find it.
I can compile exactly the same source successfully on the BBB itself. Running ldd on that reveals:
libstdc++.so.6 => /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 (0xb6e56000)
libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0xb6dea000)
libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0xb6dc6000)
libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6ce8000)
/lib/ld-linux-armhf.so.3 (0xb6f10000)
Running ldd on a version that Eclipse built properly reveals:
libstdc++.so.6 => not found
libm.so.6 => /lib/arm-linux-gnueabi/libm.so.6 (0xb6e55000)
libgcc_s.so.1 => /lib/arm-linux-gnueabi/libgcc_s.so.1 (0xb6e2b000)
libc.so.6 => /lib/arm-linux-gnueabi/libc.so.6 (0xb6cf3000)
/lib/ld-linux.so.3 (0xb6f0e000)
Since the goal here is to be able to build larger programs than will happily compile on the BBB, this is a real sticking point. Any ideas?
Unfortunately the instructions in the video are for deploying to Angstrom with soft floats. I will have to update it when I get finished with the book. Your local build is using hard floats, so my guess is that you need to use an armhf compiler on the desktop installation, rather than the soft float compiler that you are currently using.
If you are building from debian/ubuntu desktop Linux you can use:
# apt-get install build-essential
# apt-get install libc6-armhf-cross
# apt-get install libc6-dev-armhf-cross
# apt-get install binutils-arm-linux-gnueabihf
# apt-get install linux-libc-dev-armhf-cross
# apt-get install libstdc++6-armhf-cross
# apt-get install gcc-4.7-arm-linux-gnueabihf
# apt-get install g++-4.7-arm-linux-gnueabihf
And then use arm-linux-gnueabihf-g++ (or arm-linux-gnueabihf-g++-4.7) as your desktop compiler etc. Do the same for gcc and as.
Faced this issue. Rsolved as I changed my tool chain to hf. Thank You Derek:)
Thanks Derek! I needed to add:
deb http://www.emdebian.org/debian unstable main
to my /etc/apt/source.list file, then
sudo apt-get install emdebian-archive-keyring
sudo apt-get update
Following that, I installed the updates you gave above and modified the include locations as well as the compiler tools (which needed the -4.7 suffix in each case).
Then everything just worked
The following link was useful: http://linux-sunxi.org/Toolchain
Thanks again!
Thank you SteveC and of course Derek for clarifying this. I managed to get the arm-linux-gnueabihf installed and configured on the Eclipse. I used the latest available 4.8.2 c++ include files.
I’m running on rev C of BBB with Debian distribution.
On my PC, I have Ubuntu 14.04 running in Virtual box within Windows 7.
Just to clarify on solving the error that occurs when you attempt this guide on a BBB with debian install:
“error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory”
Derek was indeed right in his comment above that you need the gnueabihf (hard float) tool chain. However, the only thing that I needed to do to fix this error was:
> apt-get install g++-arm-linux-gnueabihf
I really appreciate, Steve C. It works perfectly.
So near yet so far – I managed to follow your video and get cross-compiling for BBB working for simple c++ – but then have been completely defeated by setting up CURL – the novice very quickly discovers that they have strayed into grown-ups territory – no off-the-shelf instructions that apply to one’s specific circumstances, and a vast amount of new learning required if you want to be able to work out what you ought to be doing. If anyone does know of simple instructions on CURL, I’d love to try them, but otherwise I guess it is time to forget c++ and see if I can make do with bonescript, or go back to the Arduino.
Derek:
In the video, you mentioned that you were having trouble getting Eclipse to auto-magically push the compiled executable into the BBB. Since it is over a year since you made the video, you may have figured it out by now, but the following will work, after the “Remote Systems” has been configured to access the target BBB using SSH as described in your video.
In my case, I put my executables in the BBB at /home/debian/bin/
my BBB fixed IP is 192.168.1.201
and I sign in as “root” on the debian distribution BBB system via “Remote Systems”
Add post compile instructions at this location:
[Project]/Properties/C-C++ Build/Settings/Build Steps/Post-build steps Command:
The post compile command to copy the executable into the radio
scp [ExwecutableName] root@192.168.1.201:/home/debian/bin/
Best regards,
— Graham
==
Hi Derek,
I know its very basic, but I keep getting the error
/bin/sh: 1: arm-linux-gnueabi-4.6-g++: not found
make: *** [src/test.o] Error 127
could you spare a second and please answer.
thanks in advance
Hi
I’ve been watching your videos on Beaglebone and I really enjoyed them. Thank you very much
I just have one question. I have another ARM9 board (Mini2440) and I couldn’t get Remote System Explorer to work with my board inside eclipse (I have ubuntu on VirtualBox and host is Win7)
What do you think the problem is?
I have not installed Java on my board. Is it necessary to install Java on my board?
I don’t want to run any Java code. I just want to connect remotely to my board for developing C/C++ applications.
How do I fix this? or where might have I gone wrong? Regards Simon
ubuntu@arm:~/HelloWorldTest$ chmod ugo+ HelloWorldTest
ubuntu@arm:~/HelloWorldTest$ ls -al
total 76
drwxrwxr-x 2 ubuntu ubuntu 4096 Oct 28 05:41 .
drwxr-xr-x 5 ubuntu ubuntu 4096 Oct 27 11:51 ..
-rwxrwxr-x 1 ubuntu ubuntu 65874 Oct 28 04:57 HelloWorldTest
ubuntu@arm:~/HelloWorldTest$ ./HelloWorldTest
-bash: ./HelloWorldTest: No such file or directory
ubuntu@arm:~/HelloWorldTest$
hello sir!
As you mentioned about the file not found error, when we work on 64 bit platform and execute on 32 bit platform on Beaglebone. how should I solve this error.is there another way. because I have tried Codeblocks and even through the terminal. the same error occurs each time. or I have to work to install 32 bit linux in my virtual box
Hi Derek,
Thanks alot for such an informative video. I am trying to setup my env for cross compilation. I am able to complete everything but the final Hello World file not running on Beagleboard. I am trying it on Beagleborad black. It is having Debian installed in it. While running the “Hello World” file on BBB it gives the following error:
root@beaglebone:~/GCC# ./Hello\ World
./Hello World: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
On my PC I have installed the gcc/g++ as specified in the video:
sudo apt-get install g++-arm-linux-gnueabi
sudo apt-get install gcc-arm-linux-gnueabi
Please advise what should be resolution?
On rechecking the compiler version on BBB the target there is usr/arm-linux-gnueabihf.
I tried changing the arm compiler version in eclispse. But this time the issue is the output file it generates is “Hello Wolrd.o”. When I try running this on BBB it says:
-bash: ./Hello World.o: cannot execute binary file
on BBB side if I do the following :
g++ Hello World.o
it generates the output a.out which is runnable but it is still not doing the reuired function on BBB. Please advice.
Bless You! That has been very helpful. The BBB community needs more like you.
Thanks for this instructive video!
I wish to know if it is at all possible to do On chip Beaglebone debugging via a Segger Jlink JTAG interface , instead of using GDBServer on the Bone and GDB client in Eclipse.
I find it terribly slow when single stepping in the C code using the software only method.
I would really like to spice up the debugging side of things
Any help is appreciated in setting this up
If you want to use JTAG with the BeagleBone Black you will need to solder a connector to the bottom of the board and use a JTAG debugger. This was much easier on the BeagleBone White. See: http://www.supermicros.org/bbb-blog/jtag-and-emulation-on-the-beaglebone-black
Hi Derek can we get a PRU introduction? im developing a custom flight controller but I cant find resources that guide me with ease into PRU C development. I want to read from IMU sensors and use a serial port for GPS logging but cant seem to get a hold on great instructions on PRU steps
Thank you
David Rodriguez
Owner of http://www.multirotorguides.com
Hi David. It’s on my list! I have written a chapter on it in my book – chapter 13 (yes, a shameless plug!). However, I focus on the use of assembly on the PRU-ICSS (it’s actually not that bad) as the C development framework is quite complex. You would need to be connecting to digital devices and for connecting to I2C, SPI or UART devices it is slightly more complex. Do you need to use the PRU for this? If you are using digital sensors that have built-in filtering you should be able to get a good sample rate, just using Linux userspace code. Derek.
Derek,
I just wanted to say thank you for the enormous amount of free education you provide online. You have greatly sped up my education on these topics and can’t wait for the book!
Warm Regards,
-Alan Essex
Thanks Alan, Derek.
Derek,
I really like your book and your videos. This is an excellent resource.
Now I’m having great difficultys adding the emdebian keyring.
The “apt-get install emdebian works fine after adding editing the sources.list, but when I apt-get update I get this: W: GPG error: http://www.emdebian.org unstable Release: The following signatures were invalid: REVKEYSIG
This is with Ubuntu 12.04 under Virtualbox under Kubuntu. Tried everything to install this keyring properly.
Thank you, Shaun
First of all I am a fan of your videos and I think it’s really impressive.
I have setup eclipse according to the video and managed to cross compile a simple “hello world” program in C and launching it on the beaglebone black.
However, I have difficulties accessing the GPIOs of the beaglebone black using eclipse, and I need to use PWMs on the GPIOs as well. How do I set this up on eclipse?
Thanks.
Solution to “file not found”:
Add “-static” to the compiler flags, this is a workaround until the real cause of the problem has been fixed.
The cause of the linking problem has to do with this:
https://wiki.linaro.org/OfficeofCTO/…athCallApr2012
Hopefully this will save you some time!
Derek,
First let me tell you a big THANK you for all the work you have posted. You made my life a lot easier. Just ordered your book and looking forward receiving it.
I do have one question for you regarding the cross compilation:
I have a project that uses some external libraries and when I try to cross-compile everything together for the BBB I get the following error:
compile command:
arm-linux-gnueabi-g++ -L/home/vaggelis/workspace/sighound/src -o “sighound” ./src/sighound.o -lHOUND -lPFFFT -lFFT -lftdi -lusb-1.0 -lftd2xx -lftdi -lpthread
error:
/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/bin/ld: BFD (GNU Binutils for Ubuntu) 2.24 assertion fail ../../bfd/elf32-arm.c:11807
No executable is generated.
When I try to compile on the BBB itself, with the native compile, I still get the same error but there is an output file generated, that seems to run fine.
After googling, I see quite a few links regarding similar issues with the binutils but no resolution. Do you happen to have come across this problem yourself?
If not, do you have any suggestions regarding how to do the compilation on the BBB, but do the debugging from Eclipse (that runs on Linux PC).
Thanks again for all the time and effort that you have put on those videos
Thanks Vaggelis for your support! I haven’t seen that error before. I did a quick search for it, and as you determined, it is problematic (see: https://sourceware.org/bugzilla/show_bug.cgi?id=16698). The alternative is interesting, but I have not tried it. You could try copying the build files back to desktop computer and executing in debug mode. I have never tried that! If it works then you could use scp to copy the files automatically to the desktop computer. Sorry I can’t be of more help, Derek.
Hello Derek,
I have seen your video of “C/C++ programming Introduction using Eclipse CDT” and thanks for sharing good informations regarding Beagle bone.
I am facing one issue, when i go for debugging of the application one message come like below
Error during file upload.
Missing element for : ”
Missing element for : ”
Missing element for : ”
how it can be resolved. Could you please help me.
I’m trying to compile your SPI ADC example. But I keep getting this error on line 20
/home/green/workspace/testarm/Debug/../src/testarm.cpp:20: undefined reference to `exploringBB::SPIDevice::SPIDevice(unsigned int, unsigned int)
I have followed the git hub steps in the book page 265. I have download your git hub repository and moved the bus folder into the usr/gnu…/includes folder. I see there is a file called libEBBLibary.so and LibEBBLibrary.a I have tried to point to them with the Cross G++ linker and added them to the paths and symbols. Not sure if that’s the right steps. Also how is namespace exploringBB being found by eclipse?
From the book exploring Beaglebone,
I follow :
….
Confi guring Eclipse for Cross‐Compilation
When Eclipse starts you should see a brief guide that describes C/C++ develop-
ment. Close it when you are ready and then test that the environment works
by creating a new project using File ➢ New ➢ C++ project. As illustrated in
Figure 7-1 (a), set the project name to “BBBTest,” pick the project type “Hello
World C++ Project,” and the Toolchain to be “Cross GCC.” Then click Finish.
Repeatedly click Next until you see the “Cross GCC Command,” as illustrated
in Figure 7-1 (b). Enter arm‐linux‐gnueabihf‐ for the cross-compiler prefi x and
set the path to /usr/bin . Finally, click Finish.
The Eclipse IDE is now confi gured for cross‐compilation using the cross‐
compilation toolchain that was set up at the beginning of this chapter.
but I got :
Description Resource Path Location Type
Program “arm‐linux‐gnueabihf-g++” not found in PATH BBBTest Project Properties, C++ Preprocessor Include…/Providers, [CDT Cross GCC Built-in Compiler Settings] options C/C++ Scanner Discovery Problem
I’ve checked on /usr/bin …those files are there …what do I miss here ?
thanks
Hi Derek,
Love the book and it’s been very helpful with getting me off the ground with the beaglebone black.
I’ve run into one minor issue with cross compilation on my linux PC. I got the Hello World example to build and run on the beaglebone black just fine. But when I started trying to run a slightly more complicated program talking to an I2C device I get an interesting error. When I run the executable on the beaglebone black it says the libc++.so.6 /usr/lib/arm-linux-gnueabihf/ doesn’t have the correct version. How do I update? I’ve gone through and tried to get my tools to the latest version with no success.
Any help is appreciated!