waelCh
Posts: 8
Joined: Sun Oct 21, 2012 8:18 pm

no such file or directory!!

Fri Dec 21, 2012 5:03 pm

Hi everyone..
i used to develop a little c++ program. I used ubuntu 12.04 -32 bits to develop my program. i have installed the "Cross Compiling Toolchain" in order to get an application wich can turn into the Raspberry.
The problem is that when i implement the program in the raspberry and i execute the command:
"./firsttest" (firsttest is the name of my application)
I got this message:
"-bash: ./firsttest: No such file or directory"
while the file "firsttest" exists!!

please i need help..!!

flyinghappy
Posts: 115
Joined: Mon Nov 05, 2012 5:31 pm

Re: no such file or directory!!

Fri Dec 21, 2012 5:04 pm

Maybe set the file to be executable? Sounds like it may be something like that...
Pi with ArchLinux running a minidlna/samba home server

waelCh
Posts: 8
Joined: Sun Oct 21, 2012 8:18 pm

Re: no such file or directory!!

Fri Dec 21, 2012 5:13 pm

I have done it and i make it executable with the command:
"chmod +x firsttest"
But nothing sound to be changed.

User avatar
redhawk
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1

Re: no such file or directory!!

Fri Dec 21, 2012 5:19 pm

If you compile a file it should automatically have the "x" executable flag.
./firstest should execute it, however using full path or `pwd`/firsttest should work as well.

Just out of curiosity you edit "firsttest" does it start with the letters "ELF" ??

Richard S.

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: no such file or directory!!

Fri Dec 21, 2012 5:31 pm

You usually get weird error messages like this when you try to execute a program compiled for one architecture on another architecture. Or, put more succinctly, when you try to run it on the "wrong" architecture.

Since cross-compilation is involved in your setup, I would look to that for the problem locus.

P.S. I used to hit this from time to time early on when I would take something from my Linux x86 boxes and try to run it on the Pi (which obviously doesn't work - but it is easy to forget that).
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

recliq
Posts: 38
Joined: Wed Jun 13, 2012 4:56 pm

Re: no such file or directory!!

Fri Dec 21, 2012 6:21 pm

file will tell you what kind of file it is, ie. if it's a binary file and for which architecture it was build:

Code: Select all

file firsttest
You should get something like this:

Code: Select all

firsttest: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=0xc410845b0312afa14b9e56dac6edaa64732c0b42, not stripped

ecw
Posts: 10
Joined: Tue Jan 10, 2012 1:56 pm

Re: no such file or directory!!

Fri Dec 21, 2012 6:36 pm

Run ldd against it. There's a chance a shared library it expects is missing.

waelCh
Posts: 8
Joined: Sun Oct 21, 2012 8:18 pm

Re: no such file or directory!!

Fri Dec 21, 2012 7:37 pm

well.. when i executed "file firsttest", i have got:
firsttest: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared
libs), for GNU/Linux 2.6.26, BuildID[sha1]=0xce75f733c0e4fce5bca9ab39a518cd6283868177, not st
ripped

and when i executed "ldd firsttest", i have got:
not a dynamic executable

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: no such file or directory!!

Fri Dec 21, 2012 8:01 pm

waelCh wrote:well.. when i executed "file firsttest", i have got:
firsttest: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared
libs), for GNU/Linux 2.6.26, BuildID[sha1]=0xce75f733c0e4fce5bca9ab39a518cd6283868177, not st
ripped

and when i executed "ldd firsttest", i have got:
not a dynamic executable
Those are certainly the right tests to run.

It tells me that:

1) It was close enough to the right thing to "fool" the "file" command. I.e., "file" isn't very exact; it pretty much just believes what you tell it.

2) It isn't close enough to actually run on the Pi - which is why "ldd" said "What is that?"

All of which means that your cross-compilation environment is not quite configured right.
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

waelCh
Posts: 8
Joined: Sun Oct 21, 2012 8:18 pm

Re: no such file or directory!!

Fri Dec 21, 2012 9:30 pm

So bad..
can you give me a great tutorial wich can describe me how to configure the toolchain suit?!

User avatar
rfrankla
Posts: 8
Joined: Sun Dec 23, 2012 7:25 pm

Re: no such file or directory!!

Thu Dec 27, 2012 11:40 pm

Hi, I created a procedure to build a cross-compiler. This is simply a record of what I did for myself, I have not cleaned it up, BUT it worked first time for me.
https://docs.google.com/document/d/1gtl ... Xa06s/edit

*** NOTE: do not move the compiler after "ct-ng build" of the compiler. If you want it in a different place you must rerun "ct-ng menuconfig" and set another in: Paths & Misc: --> Set "Prefix directory" then run "ct-ng build" again. ****

Also note: My procedure does NOT change/add-to PATH environment variable. There is no need to do this for cross-compilers, I did not need to do it to get good results!

These two notes contradict instructions in the Raspberry Pi wiki at eLinux. -- I believe the wiki is incorrect on these points.

Return to “C/C++”