LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Cross Compiling in OpenWRT. Cannot Execute binary file. Ideas? (https://www.linuxquestions.org/questions/programming-9/cross-compiling-in-openwrt-cannot-execute-binary-file-ideas-862157/)

aztroboy 02-11-2011 10:13 PM

Cross Compiling in OpenWRT. Cannot Execute binary file. Ideas?
 
Hello! I'm trying to compile a simple script for a ar71xx (bleeding edge /from snapshots) Openwrt router.

I have previously compiled scripts for Kamikaze 8.09. I just copied the gcc file inside the SDK dir and used it without problems.

Now I tried doing the same for http://downloads.openwrt.org/snapshots/trunk/ar71xx/

But every time I try to execute it:

Code:

[root@centos]# ./gcc src/hello.c -o hello
-bash: ./gcc: cannot execute binary file

Note: I downloaded the "OpenWrt-SDK-ar71xx-for-Linux-x86_64-gcc-4.3.3+cs_uClibc-0.9.32" from the previous link. I used the gcc executable inside the "staging_dir/toolchain-mips_r2_gcc-4.3.3+cs_uClibc-0.9.32/mips-openwrt-linux-uclibc/bin" directory.

So how can I compile them? Has anyone given a try?

thank you

Oliv' 02-12-2011 04:13 AM

Hello,

Please, could you post the output of the following command:
Code:

file ./gcc
regards,

Oliv'

theNbomr 02-13-2011 06:43 PM

Quote:

I just copied the gcc file inside the SDK dir
What gcc file? This sounds like you are trying to use a compiler that is intended to run on a different kind of host. By the nature of his/her question, it sounds like Oliv' may be thinking this as well. Also, when you did the copy, did the permissions on the file(s) change? Does ./gcc have executable permissions?

From the nature of your question (compile a simple script), it sounds like you don't fully understand the whole cross-development scheme. If I may read between the lines a little, it sounds like you have previously used a compiler for some other host. You are trying to run it on a different host, but not on one for which it was built. If this is the case, it may be time for you to start learning about embedded development and cross toolchains.

Perhaps provide a bunch more detail about the origins of all of the component parts.

--- rod.

paulsm4 02-13-2011 07:10 PM

aztroboy -

TheNBomr is right - it sounds like you're trying to run a copy of "gcc" that wasn't built for your host.

All you need to verify this, one way or the other, is run the command Oliv' suggested:
Quote:

EXAMPLE:
file /usr/bin/gcc

/usr/bin/gcc: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped

aztroboy 02-15-2011 12:36 AM

Thank you for your answers. I have previously worked with cross compiling with Kamikaze. What I did was to download the OpenWRT SDK, untar and copy a gcc file that came inside the buildroot folders.

You were right: I was using a gcc version that was not meant to run in my CentOS machine. What I needed was the i686 version that I downloaded from the Kamikaze distribution download page.


Thank you very much.


All times are GMT -5. The time now is 08:28 PM.