worik
Posts: 3
Joined: Mon Apr 22, 2019 10:00 pm

Error cross compile rust for zero

Sat May 25, 2019 1:46 am

I am trying to cross compile rust from ubuntu to raspberry pi zero. It compiles fine on the Zero, but is slow.

I am using target armv7-unknown-linux-gnueabihf following these instructions

When I run the executable I get: /home/pi/motion/cgi/bin/cgi: /lib/arm-linux-gnueabihf/libc.so.6: versionGLIBC_2.28’ not found (required by…`

Why?

The PI is running Raspbian GNU/Linux 9

$ arch
armv6l

I suspect the target is incorrect for the zero, or the libc versions do not match. This is my first attempt at cross compiling and I am out of my depth!

User avatar
ScriptBasic
Posts: 907
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: Error cross compile rust for zero

Sat May 25, 2019 2:02 am

I had a similar problem and solved it by adding a full path link to libc6.a.

Now that I think back, it was a missing symbol that the above fixed.
Last edited by ScriptBasic on Sat May 25, 2019 3:00 am, edited 1 time in total.

User avatar
Paeryn
Posts: 2512
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: Error cross compile rust for zero

Sat May 25, 2019 2:40 am

Yes, your target is wrong for an RPi0, programs compiled for armv7 won't run on the Zero's armv6 (it will use instructions that the RPi0's cpu doesn't have).

As to the GLIBC_2.28 error, that is because your cross-compiler linked it against a newer version of GLIBC than what is installed on the RPi. Raspbian has version 2.24 whereas your program is requiring version 2.28.
She who travels light — forgot something.

worik
Posts: 3
Joined: Mon Apr 22, 2019 10:00 pm

Re: Error cross compile rust for zero

Sat May 25, 2019 7:20 am

Paeryn wrote:
Sat May 25, 2019 2:40 am
Yes, your target is wrong for an RPi0, programs compiled for armv7 won't run on the Zero's armv6 (it will use instructions that the RPi0's cpu doesn't have).

As to the GLIBC_2.28 error, that is because your cross-compiler linked it against a newer version of GLIBC than what is installed on the RPi. Raspbian has version 2.24 whereas your program is requiring version 2.28.
The correct target might be:arm-unknown-linux-gnueabi. https://forge.rust-lang.org/platform-support.html suggests it is for: ARMv6 Linux.

How do I get it to use a different glibc?

User avatar
Paeryn
Posts: 2512
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: Error cross compile rust for zero

Sat May 25, 2019 11:45 am

worik wrote:
Sat May 25, 2019 7:20 am
Paeryn wrote:
Sat May 25, 2019 2:40 am
Yes, your target is wrong for an RPi0, programs compiled for armv7 won't run on the Zero's armv6 (it will use instructions that the RPi0's cpu doesn't have).

As to the GLIBC_2.28 error, that is because your cross-compiler linked it against a newer version of GLIBC than what is installed on the RPi. Raspbian has version 2.24 whereas your program is requiring version 2.28.
The correct target might be:arm-unknown-linux-gnueabi. https://forge.rust-lang.org/platform-support.html suggests it is for: ARMv6 Linux.

How do I get it to use a different glibc?
You want the hf one else the loader will complain about incompatible floats: arm-unknown-linux-gnueabihf

You need to make sure the cross-compiler links with the same version glibc that the RPi uses. When I've done cross-compilers before I've copied the RPi libs over so I know the correct versions are being used, though I've not cross-compiled with rust, I just let rustup do its thing on the RPi.

Addendum:
I found these instructions for building for the RPi, they give it as a docker file but you can easily run the commands yourself.
https://github.com/japaric/rust-cross/issues/42
She who travels light — forgot something.

Return to “Other programming languages”