OpenWrt Forum Archive

Topic: Howto execute custom binary?

The content of this topic has been archived on 28 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

hey,

I'm just trying to figure out how to run a custom binary on my i386 openwrt machine running kamikaze 7.06...
For testing I compiled a simple hello.c world prog on my debian x86 linux, copied it with wget to my openwrt machine and made it executable with "chmod +x filename"...

But I can't run it... whenever I try "./filename", it says
"/bin/ash: ./filename: not found"

on my debian linux "./filename" works as expected

What is missing?
thx

are you root?
if not search the forum for "setuid". maybe that helps.
bye

you have to cross-compile your program. use the buildsystem to do cross-compiling and it'll work...

thanks for your reply.

well yes, I am root. I'm actually trying this on the console...

Command:
root@OpenWrt:/usr/sbin# ./hello

ls -la hello:
-rwxr-xr-x    1 root     root         7013 Jun 11 11:03 hello


any more ideas? smile

yeah, I read about cross-compiling, I just can't figure out why I have to do it in this case?
I mean, if I compile it on a x86 debian linux, why can't I use this binary on my openwrt x86 system?
Of course I have to cross-compile if I want the binary to run on a mipsel router for example.... but x86?

Actually I'm just trying to find another way to create ipk packages. My idea was:
I noticed that ipk packages are nearly equal to debian packages except the compression method, and that many ipkg packages contain a precompiled binary. So I just thought about grabbing an available mipsel package and replacing the mipsel binary with an available binary from a ..._i386.deb package, or to cut down the size of the debian packages and rebuild them as ipk packages. Well I have already done this, ipkg install is doing fine... unfortunately I cannot execute the binary...

See this link:
http://www.intrinsyc.com/support/i-linu … ckages.htm

So I tried it with a simple hello world prog that I compiled on my debian x86, copied it and well, I can't run it also.

Can someone please explain this to me? So I'm absolutely wrong with my idea?
actually the ipkg also contain precompiled binaries..

thx

cyberjunk wrote:

yeah, I read about cross-compiling, I just can't figure out why I have to do it in this case?
I mean, if I compile it on a x86 debian linux, why can't I use this binary on my openwrt x86 system?

simple. x86 debian is glibc based. openwrt uses uclibc -> binaries are not compatible.

Forum2006 is right..
One more way (without any practical sense) is to build the executable with all required libraries statically linked using debian Linux gcc.

Ok, thanks a lot.

I've downloaded the SDK and I'm playing around with it a bit... can't get the helloworld sample from the wiki run yet..

Actually my goal is to create a asterisk, vpnc and openvpn x86 package.
I noticed that there are already makefiles for them:
https://dev.openwrt.org/browser/packages/net/openvpn

So what do I have to do to build them from svn? Where to put the downloaded openvpn sources?
Is this an "easy" task, or is there much more to do than putting the right files together and run a command to compile it?

The discussion might have continued from here.