Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a large application I have written. I can successfully compile the application in the following scenarios:

  • in a native compilation for the i386 host running Ubuntu 12.04
  • natively on a PandaBoard running Ubuntu 12.04 (this takes a long time)
  • using Qemu and a chroot on the host PC for the armhf PandaBoard target (this takes a very long time)

I would like to cross-compile the application on the i386 host to run on a target such as the PandaBoard to complete builds in a timely fashion. So far attempts made using the arm-linux-gnueabihf tool chain in the repositories has produced binaries that do not run correctly. At this stage, I have no plans to package the software.

What is the recommended way to achieve a successful cross-compile?

share|improve this question
    
Cross-compiling with the cross-compiler toolchain should work, that's what it's for. In what way do the binaries not run correctly? –  Gilles May 2 '12 at 20:59
    
My binaries terminate almost immediately. strace seems to indicate that libc.so.6 isn't where it is expected to be. –  Jonathan Cave May 2 '12 at 22:28
    
That should be fixable by a link option (I don't know which one offhand). Is the target system running Ubuntu? –  Gilles May 2 '12 at 22:29
    
Yes target is also running Ubuntu 12.04. I had thought that maybe I needed to use the --sysroot option to the compiler and linker, but this is disabled in the Ubuntu toolchain. –  Jonathan Cave May 3 '12 at 8:57
    
The toolchain Just Works for me, on 12.04. I've just tested it on amd64, and successfully ran the binary it produced on an armhf server. But I don't have an i386 build machine handy. If you're still having problems, you'll need to elaborate. What does ldd say? What did you see from strace that took you to your conclusion? See if you can reduce your problem to a simple test case which should clearly work, and present the steps you are taking in detail. –  Robie Basak Jul 5 '12 at 22:03

1 Answer 1

https://wiki.linaro.org/Platform/DevPlatform/CrossCompile/UsingMultiArch

https://wiki.ubuntu.com/MultiarchCross

Ubuntu has a cross-toolchain, apt-get install gcc-arm-linux-gnueabihf but work on the next-gen toolchain is discussed here: http://gsoc.sitedethib.com/posts/apt-get_install_gcc-4.7-arm-linux-gnueabihf/

There are a number of workarounds that are necessary at this point. For example, if you use indirect linking (covered in the linaro wiki page.) You also should avoid running foreign binaries right after compiling them.

Also, its really most mature with autotools.

I got my package to cross-compile fairly quick.

apt-get build-dep -aarmhf foo-pkg
apt-get source foo-pkg
cd foo-pkg-*
dpkg-buildpackage -aarmhf
share|improve this answer
1  
Please explain what these steps do, and what the switch -aarmhf is. They are not familiar to many users, requiring them to search yet another layer deeper to get a usable answer. Thanks. –  garyp Nov 19 '12 at 19:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.