Ubuntu – Help with cross-compiling for ARM

armcross-compilationgcc

I have recently been trying to cross-compile programs for ARM. However, when I run make, I always get an error within a minute or less that says something like

/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lgio-2.0.

The thing that confuses me is that I get that error every time I try to cross-compile a program (except it doesn't always say that it can't find -lgio-2.0. It has trouble finding other things too). Is there something I'm doing wrong? Why is it always this error? The only program I have been able to successfully cross-compile is bash, but I've had problems with everything else. What do I do? I have all of the libraries and things installed, as I am able to natively compile the programs just fine.

Best Answer

As mentioned by muru. You need to install the ARM architecture of that library. However they are not listed on http://packages.ubuntu.com site. Neither, it's easy to manage dependencies manually that way.

Note: Setup a chroot environment, I found weird behavior when I added armhf architecture to my Ubuntu 15.04 amd64. I used dpkg --add-architecture=armhf. The APT start complaining about broken package wine and tried to remove all i386 packages.

  1. Add new sources file

    sudo nano /etc/apt/sources.list.d/arm-repo.list
    

    Add the source of the architecture you want and release you have.

    deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports trusty main universe
    

    Check for available arch here: http://ports.ubuntu.com/ubuntu-ports/dists/trusty/main/ as you can browse up/down for different releases.

  2. Update package list

    sudo apt-get update
    
  3. Add a dpkg configuration

    sudo nano /etc/dpkg/dpkg.cfg.d/multiarch
    

    with this line

    foreign-architecture armhf
    
  4. Install need packages as needed, example:

    sudo apt-get install libglib2.0-0:armhf
    

References:

Related Question