a simple application cannot execute on debian

Started by kimdou, November 29, 2014, 04:53:09 PM

Previous topic - Next topic

kimdou

just one line to print hell.
test.c:
#include <stdio.h>
#include <unistd.h>
#include <malloc.h>
#include <pthread.h>
int main(int argc, char** argv)
{
   printf("hello this is test.\n");
   return 0;
}

on the pc:
arm-linux-gnueabihf-gcc -Wall -O0 -g -o test.exe test.c
(gcc version 4.6.3 (Debian 4.6.3-14))

file test.exe
ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=0x2ec9f38d30359507d204aa5375ece9603234e371, not stripped

copy to the u-disk connect to USB port of the board, and mount to /mnt
# ./test.exe
-sh: ./test.exe: not found

but the sh is ok:
# sh --help
sh --help
BusyBox v1.18.3 (2014-11-10 07:13:37 EST) multi-call binary.

No help available.

what's the possible problem?

Gerrit

Most likely you did not cd to the directory with test.exe in it
or else you did not make it executable (.exe does not make executable) chmod a+x ./test.exe does

MBR

#2
Yes, in Linux, as in all unices, does not matter what extension the file has (only the Windows are obsessed with extensions) as long as it has set the executable flag(s) (the 'x' in the first column of ls -l), see man chmod for more information what the various flags do.

BTW, if you put an executable file on a removable media (SD card, USB flashdisk or such) with a FAT32 filesystem (the factory default), it will lose all its unix attributes (unless you use a weird thing called UMSDOS). When you mount it again on antoher Linux machine, the state of executable flag will depend on the mount options (especialy on the fmask mask). If you don't want this behaviour, transfer the files as tarballs, because tar keep all unix atrributes intact.

kimdou

Quote from: MBR on December 02, 2014, 07:50:23 AM
Yes, in Linux, as in all unices, does not matter what extension the file has (only the Windows are obsessed with extensions) as long as it has set the executable flag(s) (the 'x' in the first column of ls -l), see man chmod for more information what the various flags do.

BTW, if you put an executable file on a removable media (SD card, USB flashdisk or such) with a FAT32 filesystem (the factory default), it will lose all its unix attributes (unless you use a weird thing called UMSDOS). When you mount it again on antoher Linux machine, the state of executable flag will depend on the mount options (especialy on the fmask mask). If you don't want this behaviour, transfer the files as tarballs, because tar keep all unix atrributes intact.

thanks,the problem is the application is dynamically linked, the ld-linux.so version is not crect.
in the tool-chain: use -Wl,--dynamic-linker=/lib/ld-linux.so.2 could resolve the problem.