Cross-compiling Rust for Pinephone
#1
Hello,
has anybody successfully cross-compiled a gtk application for the Pinephone? I was able to cross-compile a basic hello-world example but compiling the examples from the Relm crate gave me a bunch of errors. This my first time cross-compiling so I feel like I might be missing something obvious. I am running Arch Linux on my host and the errors I am getting are:

Code:
= note: /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lgtk-3
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lgdk-3
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lz
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lpangocairo-1.0
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lpango-1.0
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lharfbuzz
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -latk-1.0
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lcairo-gobject
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lcairo
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lgdk_pixbuf-2.0
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lgio-2.0
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lgobject-2.0
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lglib-2.0
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -latk-1.0
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lgobject-2.0
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lglib-2.0
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lgdk-3
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lz
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lpangocairo-1.0
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lpango-1.0
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lharfbuzz
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lgdk_pixbuf-2.0
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lcairo-gobject
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lcairo
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lgobject-2.0
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lglib-2.0
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lpango-1.0
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lgobject-2.0
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lglib-2.0
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lharfbuzz
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lgdk_pixbuf-2.0
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lgobject-2.0
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lglib-2.0
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lgio-2.0
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lgobject-2.0
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lglib-2.0
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lgobject-2.0
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lglib-2.0
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lcairo-gobject
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lcairo
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lgobject-2.0
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lglib-2.0
          /usr/lib/gcc/aarch64-linux-gnu/10.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lglib-2.0
         
          collect2: error: ld returned 1 exit status
          error: aborting due to previous error
          error: could not compile `relm-examples`.
#2
How do I get the necessary libraries to successfully compile the application? I could not find them in the Arch repository or in the AUR. Does that mean I have to cross-compile them from source and move them to the expected folder? If so, what would be the starting point to do so?
#3
on debian/ubuntu, those are usually marked with the suffix -dev, like gtk-dev
on fedora/centos/rhel etc. they are usually marked as -devel
unfortunately, no idea how this works on arch linux
but you could use pkgfile to see what packaga provides those

edit: https://www.archlinux.org/packages/extra/x86_64/gtk3/
they contain the devel files, so those files should be installed when installing e.g. cairo, atk, pango etc.

you could check how those packages are built by archlinux (i am sure they have some CI/CD system) or maybe ask in #archlinux
#4
Thank you for your suggestions, they gave me a few ideas.
In the Arch repository you can see the architecture a package is meant for. On most of them it says its for x86_64[/url] but some say amy. For the gtk3 package it also says its for x86_64[url=https://www.archlinux.org/packages/?arch=x86_64]. I thought this might be my mistake and the solution could be to find the same libraries but for aarch64 so I had a look at Arch Linux on ARMs packages. The missing packages are listed there. I am going to download those files and try it again. No clue if this is how it works but I guess we'll see..
Smile
#5
I successfully cross-compiled the examples  Smile

The way I did it was less than optimal though I think. I read through the errors listed when trying to compile them and searched for those libraries on https://archlinuxarm.org/packages. All the packages I needed were available there so I downloaded each package and extracted them. Some had the extension .tar-1 or something similar after unpacking. I renamed them to .tar and unpacked them again. They all had a folder called usr. I copied the folder /usr/aarch64-linux-gnu to make sure I can revert the changes in case I break something and then copied the content of the usr folder of all the downloaded packages into the folder /usr/aarch64-linux-gnu. Then I tried compiling again. Now different libraries were missing (the dependencies of the newly added libraries) and I repeated the whole process for those missing libraries until none were missing and I successfully compiled the examples.

Its not a very elegant solution and involved a lot of copy and pasting so now I will look into how to add the necessary packages to the AUR so others can get those libraries easier
#6
(Relm's author here.)

I just got my PinePhone and wanted to play with that as well Wink .

I wrote a draft tutorial explaining the steps I found to fix this issue.
Use at your own risk, though, because that might mess up with your installed pacman files if I forgot something.

Good luck and have fun!


Possibly Related Threads…
Thread Author Replies Views Last Post
  eSIM on PinePhone just_a_q 8 4,678 11-05-2024, 11:10 AM
Last Post: zetabeta
  Want to buy second hand PinePhone 3G version rudi.timmermans 0 172 11-01-2024, 09:58 AM
Last Post: rudi.timmermans
  Can use PlayStation on Pinephone? willharper 6 5,678 10-30-2024, 08:07 AM
Last Post: biketool
  Ordered PinePhone till today have no info or confirmation about order hennadiyt 1 359 10-05-2024, 02:20 PM
Last Post: KC9UDX
  US Mobile, via T-Mobile, won't support Pinephone Pro - SOLVED, SIMPLY jovval 11 5,761 07-28-2024, 03:42 PM
Last Post: dchang0
  How can I record video on a Pinephone? kk22 18 7,206 07-22-2024, 05:18 PM
Last Post: baptx
  Pinephone not booting, always vibrating alexander12 8 6,881 07-19-2024, 07:50 PM
Last Post: Blackheart
  PinePhone Pro P. Siera 2 825 07-17-2024, 12:41 AM
Last Post: P. Siera
  PinePhone Boots but only Shows Black Screen with Backlight danyeaw 1 688 06-30-2024, 10:18 AM
Last Post: danyeaw
  Pinephone won't boot. spha 13 5,898 05-15-2024, 10:31 PM
Last Post: Richy_T

Forum Jump:


Users browsing this thread: 2 Guest(s)