0

I need to run some USB NCM related test cases for which i have written some test code in .c file. I have compiled the .c file from Ubuntu Host by using GCC compiler and trying to run from Device's console but i'm getting "-sh: Cannot execute binary file" error. Device side we don't have GCC installed.

uname -a command gives following o/p in,

> Host:

    4.4.0-31-generic Ubuntu x86_64

> Device:

    3.14.55-yocto-standard #1 SMP PREEMPT Fri Oct 12 13:34:50 CEST 2018 i686 GNU/Linux

I understand that there is environment difference from Host to Device. Anyways i need to compile and execute .c file in device side console.

2

x86_64 and i686 instruction sets are not the same (for more details).

Use this command to compile source on your host :

 gcc -m32 -mtune=i686 source.c -o source  

if getting error like this fatal error: *.h : No such file or directory this means that you don't have proper a library for cross compilation

 sudo apt install g++-multilib

And run gcc command again

Reference :

GCC man page

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.