Cross-compiling to armhf/beaglebone black

Need help with C, C++, perl, python, etc?

Cross-compiling to armhf/beaglebone black

Postby rsfairman » 2017-01-24 20:39

The gist of my question is how to cross-compile from an i386 to ARM. It seems like different package installations are hiding previous installations, and the compiler can't find libraries, etc.

I want to cross compile from an i386 machine running Debian 8.7.1 to an ARM machine (a Beaglebone Black, also running Debian). The aim is to use CodeBlocks and wxWidgets with C++ on the i386 to write a GUI which will run on the BBB. Ideally, I want to compile and test entirely on the i386, then flip a few compiler switches to get a version that will run on the BBB once the code is "done" (and periodically during the development process). I'm not totally wed to using CodeBlocks or wxWidgets, though I have experience with both, and I don't think either of those is relevant to the problem I have.

I first installed build-essential, then CodeBlocks, and wxWidgets, and that went fine. All of the sample code that comes with wxWidgets compiled without a hitch and the programs run fine (and still run fine). Then I followed the directions at
http://exploringbeaglebone.com/chapter7/
for installing the packages to allow cross-compiling. Molloy's book is very good, by the way. He has you do

dpkg --add-architecture armhf
apt-get install cross-build-essential-armhf

However, the last step failed due to some missing libraries, which Molloy (the website mentioned) does not discuss, so I installed linux-libc-dev:armhf and libc6-dev:armhf, and the install of cross-build-essential-armhf worked. But it seemed to make g++ (for the i386) disappear so I installed build-essential again (a bad sign).

After the above steps, I can compile (for i386) and cross-compile (for BBB) a simple "hello world" program. However, when I try to compile something which relies on other libraries, the linker can't find them. For example, gthread-2.0, gtk-3, gdk-3, etc., a fairly long list.

Looking at /usr/lib/i386-linux-gnu, it appears that these .so files are there, but the symbolic links have been removed. For instance, libgthread-2.0.so.0 is there, but not a symbolic link to it from libgthread-2.0.so. In fact, libgthread-2.0.so does not exist, though it must have existed (I guess) when the wxWidgets example code was compiled during the wxWidgets installation process.

I could go in and manually create a dozen or more symbolic links that are missing, but I have the feeling that I'm missing some critical element in the big picture of how to cross-compile, and that this kind of manual fix would only be a band-aid on the underlying problem. I also wonder about the fact that /etc/ld.so.conf now includes directories for ARM. Should it?
rsfairman
 
Posts: 20
Joined: 2017-01-18 22:16

Re: Cross-compiling to armhf/beaglebone black

Postby stevepusser » 2017-01-24 22:31

I'm 99.9% sure you'll need the armhf -dev versions of all those libraries you want it to link to. It isn't much use for an armhf program to link to an i386 version of libgtk2.0.

I was able to compile a few Rasberry Pi versions of programs in a Qemu virtual machine on my amd64 machine by following this guide: https://jodal.no/2015/03/08/building-ar ... -pbuilder/
The MX Linux repositories: Backports galore! If we don't have something, just ask and we'll try--we like challenges. New packages: AzPainter 2.1.0, Pale Moon 27.5.0, Liquorix kernel 4.12-10, mpv 0.27.0, Kodi 17.3, 0ad 0.0.22, Mesa 13.0.6
User avatar
stevepusser
 
Posts: 8804
Joined: 2009-10-06 05:53

Re: Cross-compiling to armhf/beaglebone black

Postby rsfairman » 2017-01-24 23:22

True enough -- I do need the armhf libraries for my program to link to when compiling the ARM version of the program, particularly since I am hoping to use static linking of everything the program uses. But I have yet to cross that bridge.

Right now, the issue is that the i386 libraries are messed up -- not seriously messed up, as far as I can tell, but not quite right either. Leaving ARM entirely to the side, regular i386 programs don't compile. I suspect that installing the armhf stuff somehow messed up a pre-existing fully functional (?) i386 development setup. I could figure out on a case-by-case basis which symbolic links to which libraries are missing, and create them myself, but this seems crude, and like I've overlooked something important.

I am unfamiliar with qemu and pbuilder, but if I understand, you are suggesting that I use qemu to set up a virtual machine to emulate the Beaglebone (the ARM), then build and test there. So, I might write the code on the i386 and compile and test as usual, then do exactly the same thing on the virtual ARM machine, with all the same tools, but after compiling/installing them on the virtual machine. Or I could do every bit of development in the emulator (though it would be slower), ignoring my regular development toolchain. I like this idea, though it does feel like a "gold plated hammer." But it's not clear what role pbuilder would play since the goal isn't a package as such, but a single .exe file.
rsfairman
 
Posts: 20
Joined: 2017-01-18 22:16

Re: Cross-compiling to armhf/beaglebone black

Postby stevepusser » 2017-01-25 02:55

I only used the method in the guide to compile already debianized source files into proper deb packages. I suppose that the same method would work if your project was also debianized.
The MX Linux repositories: Backports galore! If we don't have something, just ask and we'll try--we like challenges. New packages: AzPainter 2.1.0, Pale Moon 27.5.0, Liquorix kernel 4.12-10, mpv 0.27.0, Kodi 17.3, 0ad 0.0.22, Mesa 13.0.6
User avatar
stevepusser
 
Posts: 8804
Joined: 2009-10-06 05:53


Return to Programming

Who is online

Users browsing this forum: No registered users and 5 guests

fashionable