LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 02-11-2011, 10:13 PM   #1
aztroboy
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 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
 
Old 02-12-2011, 04:13 AM   #2
Oliv'
Senior Member
 
Registered: Jan 2004
Location: Montpellier (France)
Distribution: Gentoo
Posts: 1,014

Rep: Reputation: 36
Hello,

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

Oliv'
 
Old 02-13-2011, 06:43 PM   #3
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
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.
 
Old 02-13-2011, 07:10 PM   #4
paulsm4
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:
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
 
Old 02-15-2011, 12:36 AM   #5
aztroboy
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 01:07 AM.
 
  


Reply


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 01:51 PM
cannot execute binary file rolandandy Linux - Newbie 2 10-09-2007 10:35 AM
Cross compiling to Windows binary, including Linux shared libraries Siiiiiii Programming 2 03-09-2007 12:36 AM
Cannot execute binary file sonia gulrajani Programming 3 11-05-2006 01:30 AM
Cannot execute binary file Sigh Linux - Server 4 09-22-2006 07:43 AM


All times are GMT -5. The time now is 10:34 PM.

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