Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 02-11-2011, 11:13 PM   #1
LQ Newbie
Registered: Jun 2010
Posts: 19

Rep: Reputation: 0
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

But every time I try to execute it:

[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
Old 02-12-2011, 05:13 AM   #2
Senior Member
Registered: Jan 2004
Location: Montpellier (France)
Distribution: Gentoo
Posts: 1,014

Rep: Reputation: 36

Please, could you post the output of the following command:
file ./gcc

Old 02-13-2011, 07:43 PM   #3
LQ 5k Club
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,397
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
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.
Old 02-13-2011, 08:10 PM   #4
LQ Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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:
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
Old 02-15-2011, 01:36 AM   #5
LQ Newbie
Registered: Jun 2010
Posts: 19

Original Poster
Rep: Reputation: 0
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.

Last edited by aztroboy; 02-15-2011 at 02:07 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot execute binary file idrissess Linux - Newbie 3 07-29-2010 02:51 PM
cannot execute binary file rolandandy Linux - Newbie 2 10-09-2007 11:35 AM
Cross compiling to Windows binary, including Linux shared libraries Siiiiiii Programming 2 03-09-2007 01:36 AM
Cannot execute binary file sonia gulrajani Programming 3 11-05-2006 02:30 AM
Cannot execute binary file Sigh Linux - Server 4 09-22-2006 08:43 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:12 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration