LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 04-06-2016, 08:12 AM   #1
sirivellavenkatesh477
LQ Newbie
 
Registered: Nov 2015
Posts: 7

Rep: Reputation: Disabled
Unable to execute appliccation binary on arm based boards


Hi All,

I have built own-cross compiler toolchain using crosstool-ng source code.

built successfully.

I have compiled my helloworld.c programme using own cross compiler toolchain
"arm-linux-gcc -o app helloworld.c"

compiled successfully...

but,the app binary is not executing when i dump that app binary into board rootfs/

rootfs# cp /media/venkat/app /bin
rootfs/bin# ./app
throwing error:
-sh: ./app: No such file or Directory.

can anyone help me plz........

Thanks in Advance...
 
Old 04-06-2016, 09:01 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,485

Rep: Reputation: 7939Reputation: 7939Reputation: 7939Reputation: 7939Reputation: 7939Reputation: 7939Reputation: 7939Reputation: 7939Reputation: 7939Reputation: 7939Reputation: 7939
Quote:
Originally Posted by sirivellavenkatesh477 View Post
Hi All,
I have built own-cross compiler toolchain using crosstool-ng source code. built successfully.

I have compiled my helloworld.c programme using own cross compiler toolchain
"arm-linux-gcc -o app helloworld.c"

compiled successfully...but,the app binary is not executing when i dump that app binary into board rootfs/

rootfs# cp /media/venkat/app /bin
rootfs/bin# ./app
throwing error:
-sh: ./app: No such file or Directory.

can anyone help me plz........Thanks in Advance...
Again, as in your other thread, don't use text speak.

And the error is very obvious: the file "app" isn't in the directory where you are. Did you try running it with "/media/venkat/app" first, to see if there's an actual problem with the app?? The error is telling you it can't find that file, not that you have a compilation error.
 
Old 04-06-2016, 09:50 AM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,563

Rep: Reputation: 7254Reputation: 7254Reputation: 7254Reputation: 7254Reputation: 7254Reputation: 7254Reputation: 7254Reputation: 7254Reputation: 7254Reputation: 7254Reputation: 7254
or try: /bin/app or just simply app (it depends on your PATH settings too)
 
Old 04-06-2016, 01:36 PM   #4
blue_z
Member
 
Registered: Jul 2015
Location: USA
Distribution: Ubuntu, Lubuntu, Mint, custom embedded
Posts: 104

Rep: Reputation: Disabled
Quote:
Originally Posted by sirivellavenkatesh477 View Post
throwing error:
-sh: ./app: No such file or Directory.
You can debug this issue by using the strace command, i.e. `strace ./app`
The last open() (which fails) will be the missing file (probably a shared library).

You could get an error message like that because of a mismatch between your toolchain libc and the shared libraries installed on the target's rootfs. For example, your toolchain might use glibc, whereas the rootfs has uClibc.

The q&d solution is to build your application with the -static option, so that it is self-contained and requires no external libraries when executed.

Regards

Last edited by blue_z; 04-06-2016 at 01:48 PM.
 
Old 04-07-2016, 02:15 AM   #5
sirivellavenkatesh477
LQ Newbie
 
Registered: Nov 2015
Posts: 7

Original Poster
Rep: Reputation: Disabled
Hi,

my app binary is present in rootfs/bin directory.

app binary built using own cross compiler toolchain, for to create own cross compiler toolchain i have followed the video in youtube.
https://www.youtube.com/watch?v=3YyH4q9lIAY

rootfs/bin#ls -lrt app
it shows the details of file app.

but when i give run this app its throwing error:
rootfs/bin# ./app
-sh:./app: No such file or directory.

-----------------------------------------------------------------------------------------------------------

if i built app binary using cross compiler tool chain which is installed with " sudo apt-get install arm-linux-gnueabi-"

compilation: arm-linux-gnueabi-gcc -o app helloworld.c
it is success...

when i dump this app binary into board rootfs/bin directory and executing it is giving an output of my programme.

rootfs/bin# ./app
Hello world

------------------------------------------------------------------------------------------------------------
But i dont want to build my app using sudo cross compiler.
i want to run app binary with own cross compiler.

please help me...

great thanks...
 
Old 04-07-2016, 02:46 AM   #6
blue_z
Member
 
Registered: Jul 2015
Location: USA
Distribution: Ubuntu, Lubuntu, Mint, custom embedded
Posts: 104

Rep: Reputation: Disabled
Compare the runtime dependencies of each compiler's output:
Code:
strings app | grep "\.so"
 
Old 04-07-2016, 02:59 AM   #7
sirivellavenkatesh477
LQ Newbie
 
Registered: Nov 2015
Posts: 7

Original Poster
Rep: Reputation: Disabled
Hi blue_Z,

yes, i have checked for both app binaries.

app binary which is created with "sudo apt-get install arm-linux-gnueabi-" has runtime dependencies.
this app binary has
venkatesh@venkatesh:~$ strings Sample_test | grep "\.so"
/lib/ld-linux.so.3
libc.so.6
venkatesh@venkatesh:~$

This will get executed in board
--------------------------------------------------------------------------------------

app binary, which built with own cross compiler tool chain has runtime dependencies are:

venkatesh@venkatesh:~$ strings app | grep "\.so"
/lib/ld-uClibc.so.0
libc.so.0
venkatesh@venkatesh:~$

where as, this will not get executed in board.
---------------------------------------------------------------------------------------

yes, both are different...

what next blue_z !!!
 
Old 04-07-2016, 03:01 AM   #8
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,563

Rep: Reputation: 7254Reputation: 7254Reputation: 7254Reputation: 7254Reputation: 7254Reputation: 7254Reputation: 7254Reputation: 7254Reputation: 7254Reputation: 7254Reputation: 7254
file ./app
 
Old 04-07-2016, 03:26 AM   #9
blue_z
Member
 
Registered: Jul 2015
Location: USA
Distribution: Ubuntu, Lubuntu, Mint, custom embedded
Posts: 104

Rep: Reputation: Disabled
Quote:
Originally Posted by sirivellavenkatesh477 View Post
what next blue_z !!!
The problem is what I mentioned in my first reply.

Quote:
Originally Posted by sirivellavenkatesh477 View Post
libc.so.6
This executable requires glibc.

Quote:
Originally Posted by sirivellavenkatesh477 View Post
/lib/ld-uClibc.so.0
This executable requires uClibc.

Your board's rootfs apparently has glibc installedl but your toolchain uses uClibc.
These libraries are not compatible; you cannot substitute one for the other.

As I previously wrote, you can use the -static switch to workaround this issue.
Or
rebuild your toolchain to use glibc instead of uClibc.
Or
rebuild the kernel and root filesystem using your toolchain.

Regards

Last edited by blue_z; 04-07-2016 at 04:56 AM.
 
Old 04-07-2016, 03:36 AM   #10
blue_z
Member
 
Registered: Jul 2015
Location: USA
Distribution: Ubuntu, Lubuntu, Mint, custom embedded
Posts: 104

Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
file ./app
The file command does not report dependencies, i.e. the shared libraries the executable needs.
Regards
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cross C compiler for LINUX based boards elico Linux - Embedded & Single-board computer 4 09-23-2012 03:04 AM
Two ARM Cortex-M3 Boards for embeded development kennyfly899 Linux - Hardware 1 07-03-2009 08:41 AM
unable to run c program , error : cannot execute binary file soni_silver17 Linux - Software 4 03-30-2009 09:45 AM
Cannot execute binary on ARM-Linux mungulish Linux - Software 0 06-01-2007 06:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 07:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration