rightaway717
rightaway717

Reputation: 2831

Can't run C++ app from linux console - "not found" error

I have 2 MIPS routers running openwrt linux. On one of them things are fine and I can easily run my app from console. I copy it over scp (this is my app, one file) to another router and when I try to run it, I get "not found" error:

root@OpenWrt:~# pwd
/root
root@OpenWrt:~# ls -l
-rwxr-x---    1 root     root        132001 Apr  2 17:37 app
root@OpenWrt:~# ./app
ash: ./app: not found
root@OpenWrt:~# uname -a
Linux OpenWrt 3.7.9 #3 Mon Aug 5 16:25:53 EEST 2013 mips GNU/Linux

I'm not a newbie in linux, but can't find what the problem is here.

Upvotes: 1

Views: 715

Answers (2)

jDo
jDo

Reputation: 4010

I'm certainly no compiler expert but from bitter experience when moving binaries around on embedded systems, this cryptic error leads me to believe that it's some sort of dependency error; likely a missing linker. Recompiling the binary on the target system has solved the issue for me in the past.

As Kevin Vasko asked in the comments: "can you run ldd ./app on it?"

This is a good way of determining which libraries and linker the program expects. One can also do as suggested in this answer that demonstrates a similar issue and run the following command to get only the "program interpreter" line (ldd will show several dependencies):

readelf -l app | grep "program interpreter"

On my system, this shows the GNU linker, ld, but with an explanatory line of text that might be helpful [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2].

Thus, I suspect that if I removed this "program interpreter" from my system, I would get the same error (and probably quite a few others). Again, try recompiling the binary on the target system or satisfy any missing dependencies manually by moving the right files into the right places.

Upvotes: 3

Kevin Vasko
Kevin Vasko

Reputation: 1645

Inside of your ./app I have a feeling you are calling something doesn't exist. In this case the "ash" command.

Based on this error

ash: ./app: not found

I feel you are running a piece of code inside of your ./app. Based on the "ash" I would say you are trying to run "bash". If I had to guess you mistyped your header in your script

#!/bin/bash

Upvotes: 0

Related Questions