Compilation not working (relocations in generic ELF)
Closed this issue · 7 comments
When i run cargo build --release --target armv5te-unknown-linux-gnueabi
it gives the following error error: linking with
cc failed: exit code: 1
.
I attached the full log: error.txt
I tried setting target.armv5te-unknown-linux-gnueabi.linker key in Cargo.toml but as you can see in the logs it isn't taken into account (warning: unused manifest key: target.armv5te-unknown-linux-gnueabi.linker
).
How did you manage to compile something for the mindstorms ev3?
Unfortunately the target configuration must be saved in the file .cargo/config
and not in Cargo.toml
.
After that the compilation should work with the docker image or another armel
-toolchain.
[target.armv5te-unknown-linux-gnueabi]
linker = "/usr/bin/arm-linux-gnueabi-gcc"
Wow! Thank you for such a quick reply! It works now!
Well, the compilation works, it's not running on the brick itself. Something about cannot execute binary file: Exec format error
Do you have any idea about why?
Can you check that the binary file and the brick have matching architectures? The output should look like this:
# On the host
file target/armv5te-unknown-linux-gnueabi/release/{binary_name}
# ... ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.3, for GNU/Linux 3.2.0 ...
# On the brick
uname -a
# Linux ev3dev 4.14.61-ev3dev-2.2.2-ev3 #1 PREEMPT Mon Aug 6 14:22:31 CDT 2018 armv5tejl GNU/Linux
$ file target/armv5te-unknown-linux-gnueabi/release/normal2
target/armv5te-unknown-linux-gnueabi/release/normal2: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.3, BuildID[sha1]=4b4f77479e64fa66c98f92b5c4a878c6809b0aa3, for GNU/Linux 3.2.0, with debug_info, not stripped
It says "shared object" which is weird ...
On the brick uname -a
gives:
Linux ev3dev 4.14.117-ev3dev-2.3.4-ev3 #1 PREEMPT Thu May 9 15:13:01 CDT 2019 armv5tejl GNU/Linux
That is really strange. I did a clean build of the docker image and a binary, installed a fresh image and executed the binary on the brick without a problem. And the Exec format error
typically indicates an architecture mismatch between the binary and the execution environment. But this seems not to be the case. If you want you can send me the binary to test if it is a problem with the build process or the execution on the brick.
It's working now.
I wasn't using docker because when I hadn't set the .cargo/config file there was an error so I tried without docker. And I didn't switch back after that. It works when I use docker.
I'll try to find a way to make it work without docker but that's not you problem :)
Thank you for helping with the .cargo/config file and sorry for bothering you uselessly after that.