C code cross compiling issue on Dragonboard410c


#1

Hi,

I want to cross-compile my c code to arm arch (dragonboard410c).by taking reference from below site


my host PC:Linux 14.04 LTS
I tried with both toolchains aarch-linux-gnu and arm-linu-gnueabihf it is compiled properly and pushing the binary into /data/local/tmp but when i try run i got the below error:

root@msm8916_64:/data/local/tmp # ./a.out
/system/bin/sh: ./a.out: No such file or directory

Please can any one suggest me how to fix this ASAP.Thanks in Advance


#2

adding some details:

->defalult android image is flashed on dragon board410C
->I also tried to compile with arm-linux-androideabi-gcc-4.8 it also cross-compiled but where running in dragonboard410c adb shell it gives me below error:

Error:Only Position Independent executable are supported

Please Let me know if you need additional info to fix this issue…


#3

Sounds like Android? If yes, please try with android toolchain in $AOSP_SRC/prebuilts/gcc/linux-x86/aarch64/.


#4

Try adding -fPIE -pie.


#5

Hi vhong,

Thankyou so much for quick reply.

I tried please find below result:

aarch64-linux-android-gcc-4.8 -fPIC -o hello.vchong hello.c

home/APQ_8016_DB410C/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.8/lib/gcc/aarch64-linux-android/4.8/include-fixed/stdio.h:50:23: fatal error: sys/cdefs.h: No such file or directory
#include <sys/cdefs.h>
^
compilation terminated.

Is anything I am missing?


#6

Hi vchong,

please find my below results:

arm-linux-androideabi-gcc -fPIC -pie -c -o hello.vchong hello.c //cross-compiling

It is cross-compiled, check my output file:

file hello.vchong, It gives below details.
hello.vchong: ELF 32-bit LSB relocatable, ARM, EABI5 version 1 (SYSV), not stripped

then I pushed it to the /data/local/tmp
but while running it is asking permissions i had given by chmod after that it shows below error:

/system/bin/sh: ./hello.vchong: not executable: 32-bit ELF file

With aarch64-linux-android-gcc it is not even cross-compiled.

FYI aarch64-linux-android-gcc bin file is in my source directory only and added in system path IS it enough right?

and didn’t install it through apt-get since i didn’t package to install.

Please provide me the steps to fix this issue.


#7

-fPIE -pie. Not -fPIC -pie. Can u please try again and post results?


#8

Hi vchong,

I tried to compile using below command:

arm-linux-androideabi-gcc -fPIE -pie -c -o hello.vchong hello.c

but,there is no change in the result.

/system/bin/sh: ./hello.vchong: not executable: 32-bit ELF file


#9

Don’t you want an executable? Why are you using -c?


#10

Hi Vchong,

Thankyou for your support I want executable only.
I treid without -c on the command and it is cross-compiled as shared object.
but while executing the program but it gives me the the warning with the expected output.
Will it create any issue?
WARNING: linker: ./hello.o has text relocations. This is wasting memory and prevents security hardening. Please fix.
Hello, World!


#11

This might be an ndk issue. If you’re using a version lower than r8c, please try upgrading and see if the warning is still there.


#12

Hi vchong,

Thank you for support for me to cross compile the c code for dragon board 410c(android image).

Now i need to cross compile the kernel module (spi driver) which is internally uses enabled spidev(/dev/spidev3.0) on the board for communicating with the hardware.

can you please suggest me how to croos-compile it without rebuilding the kernel.

Thanks in advance,
Praveen


#13

Hi Praveen,

Please see if you’re able to follow the instructions here: http://builds.96boards.org/releases/dragonboard410c/linaro/debian/latest/

You’ll have to rebuild the kernel anyway before the module, even if you don’t use the kernel image itself.

I think spidev is already built as a module anyway. Try insmod spidev or modprobe spidev and see if /dev/spidev* is created.

HTH


#14

Sorry. Above was for debian but you asked about android. See if you can follow the instructions here then: https://developer.qualcomm.com/download/db410c/linux-android-software-build-and-installation-guide.pdf