LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-14-2014, 03:08 AM   #1
why_so_serious
LQ Newbie
 
Registered: Oct 2013
Posts: 26

Rep: Reputation: Disabled
can executable file run on different Linux os?


hi, everyone, I am newbie for Linux. I have 2 Linux computers, debian and raspbian (raspberry pi). I wrote helloworld.c in debian computer and compile it. After that I sent executable file of helloworld to raspberry pi by using scp command. Raspberry pi can receive that file. But from raspberry pi, I cannot run that executable file. if I want to run, I need to send helloworld.c file and compile in raspberry pi again. If I do that, I can run. Is it because of different OS? Thanks a lot. So sorry if my question is a bit stupid. Thanks
 
Old 02-14-2014, 03:23 AM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.3, Oracle Linux, Mint
Posts: 9,669

Rep: Reputation: 398Reputation: 398Reputation: 398Reputation: 398
That's not that much because of a different OSes (they are both Linux based) but really because of different CPUs architecture. Unlike interpreted code, compiled C are binary files made of low level instructions that differ from one CPU type to another. Your debian is likely using the Intel x86 instruction set while you Raspberry PI is using the ARM one.

You either need a cross-compiler, i.e. a compiler that target a different platform than the one where it is run or directly compile on the Raspberry PI.
 
Old 02-14-2014, 03:41 AM   #3
why_so_serious
LQ Newbie
 
Registered: Oct 2013
Posts: 26

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jlliagre View Post
That's not that much because of a different OSes (they are both Linux based) but really because of different CPUs architecture. Unlike interpreted code, compiled C are binary files made of low level instructions that differ from one CPU type to another. Your debian is likely using the Intel x86 instruction set while you Raspberry PI is using the ARM one.

You either need a cross-compiler, i.e. a compiler that target a different platform than the one where it is run or directly compile on the Raspberry PI.
Hi thanks for ur answer. Now I am using gcc compiler in raspberry pi and debian computer. What are the cross - platform compiler that I can use? Thanks.
 
Old 02-14-2014, 03:45 AM   #4
Emerson
LQ Guru
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~arch
Posts: 5,894

Rep: Reputation: Disabled
This seems like good start for Debian users: http://www.emdebian.org/tools/crosstools.html
 
Old 02-14-2014, 03:47 AM   #5
why_so_serious
LQ Newbie
 
Registered: Oct 2013
Posts: 26

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Emerson View Post
This seems like good start for Debian users: http://www.emdebian.org/tools/crosstools.html
Thanks for ur precious answer. I will read through it.
 
Old 02-14-2014, 04:35 AM   #6
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware & Slackware64 14.1
Posts: 7,453
Blog Entries: 55

Rep: Reputation: Disabled
Some more info about cross-compiling for the Pi:

http://elinux.org/Rpi_kernel_compila...ing_from_Linux

Not limited to kernel building.

Last edited by brianL; 02-14-2014 at 04:39 AM.
 
Old 02-16-2014, 07:07 PM   #7
why_so_serious
LQ Newbie
 
Registered: Oct 2013
Posts: 26

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by brianL View Post
Some more info about cross-compiling for the Pi:

http://elinux.org/Rpi_kernel_compila...ing_from_Linux

Not limited to kernel building.
Hi, thanks for your answer. I will read though it
 
Old 02-16-2014, 09:00 PM   #8
docbop
LQ Newbie
 
Registered: Sep 2009
Location: Woodshed, CA
Distribution: Debian
Posts: 11

Rep: Reputation: 0
Quote:
Originally Posted by why_so_serious View Post
Hi thanks for ur answer. Now I am using gcc compiler in raspberry pi and debian computer. What are the cross - platform compiler that I can use? Thanks.
Compilters generate code for a specific CPU and I bet your one computer has an x86 family CPU and your Raspbian has ARM chip. So easy way is to compile on each computer, the other way is to use what is a cross-compiler. A cross-compiler runs on one chip type, but generates code for another chip type.
 
Old 02-16-2014, 09:03 PM   #9
why_so_serious
LQ Newbie
 
Registered: Oct 2013
Posts: 26

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by docbop View Post
Compilters generate code for a specific CPU and I bet your one computer has an x86 family CPU and your Raspbian has ARM chip. So easy way is to compile on each computer, the other way is to use what is a cross-compiler. A cross-compiler runs on one chip type, but generates code for another chip type.
Hi thanks for your answer. I will rather use cross-compiler.
 
Old 02-17-2014, 03:32 PM   #10
jefro
Moderator
 
Registered: Mar 2008
Posts: 15,890

Rep: Reputation: 2313Reputation: 2313Reputation: 2313Reputation: 2313Reputation: 2313Reputation: 2313Reputation: 2313Reputation: 2313Reputation: 2313Reputation: 2313Reputation: 2313
Isn't there some issue with endian too, depending on the os on the pi.
 
  


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
Make a file executable and then run mostafaashish Linux - Newbie 7 02-20-2014 05:34 AM
Can't run an executable file dungnguyen Linux - Newbie 7 07-02-2012 12:00 PM
Run an executable file (.exe) from matlab in a linux enviroment mca21138 Linux - Newbie 13 06-24-2011 07:20 AM
Run an executable file ( created from Qt) post installation (linux/redhat). udaypratapyati Linux - Newbie 2 02-26-2011 01:19 AM
[SOLVED] Using variable to run an executable file mahmoodn Linux - General 3 05-27-2010 06:17 AM


All times are GMT -5. The time now is 02:48 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration