Fedora Linux Support Community & Resources Center
  #1  
Old 15th July 2010, 12:20 AM
Sophie1986 Offline
Registered User
 
Join Date: May 2010
Posts: 18
linuxfedorafirefox
total newb

A couple of days ago I decided to try and make some programs in C.
I've never used any non interpreted language before (and even then my experience is pretty minimal).

What I am wondering though is, so far if I compile something on one of my computers (one has fedora, the other has gentoo), it doesn't run on the other one. I kind of expected that. One of them is 32bit and the other 64bit for one thing. And on gentoo I put march native in my make.conf.

But I gather it must be possible to compile things that work on various computers, otherwise you wouldn't be able to download binaries and run them on most ordinary PC's.

So how do you go about it? Is there somewhere where you can make once off choices to compile something very generically (since generally I wouldn't be compiling stuff to use it on both computers, and even now with the 3 line programs I am writing its not exactly a big deal, I am really just curious)?

And I suppose generally if I were going to do that I'd have to compile it on the 32bit computer then it can be used on both? But it won't work the other way round? Or am I wrong?
Reply With Quote
  #2  
Old 15th July 2010, 12:28 AM
Hlingler's Avatar
Hlingler Offline
Administrator
 
Join Date: Sep 2006
Location: Connellsville, PA, USA
Posts: 11,289
linuxkonqueror
Re: total newb

Quote:
But I gather it must be possible to compile things that work on various computers, otherwise you wouldn't be able to download binaries and run them on most ordinary PC's.
The details are definitely out of my league, but as general info: many "generic" 3rd-party binaries (e.g.: NVidia & ATI binary "blobs") are actually executable installation scripts created with makeself or equivalent, and many also include [customized/static] support libraries, all to make them more "generic" (i.e.: for use on many different Linux distros). Most also come in both 32-bit and/or 64-bit flavors. Many/most also require compilers and kernel-devel or equivalent to build/install, especially if kmods are to be built.
Quote:
And I suppose generally if I were going to do that I'd have to compile it on the 32bit computer then it can be used on both? But it won't work the other way round? Or am I wrong?
You are correct. Note however that on the 64-bit OS, the appropriate 32-bit support libraries must be available/installed.

HTH,
V
Reply With Quote
  #3  
Old 15th July 2010, 12:33 AM
Sophie1986 Offline
Registered User
 
Join Date: May 2010
Posts: 18
linuxfedorafirefox
Red face Re: total newb

Quote:
Originally Posted by Hlingler View Post
The details are definitely out of my league, but as general info: many "generic" 3rd-party binaries (e.g.: NVidia & ATI binary "blobs") are actually executable installation scripts created with makeself or equivalent, and many also include [customized/static] support libraries, all to make them more "generic". Most also come in both 32-bit and/or 64-bit flavors. Many/most also require compilers and kernel-devel or equivalent to build/install, especially if kmods are to be built.

HTH,
V
Ah, that's interesting to know.
Reply With Quote
  #4  
Old 15th July 2010, 04:54 AM
alwinl Offline
Registered User
 
Join Date: Sep 2009
Location: Northland, New Zealand
Posts: 26
linuxfedorafirefox
Re: total newb

Good on you to expand your experience.

Little tip, 'ldd' is your friend, read the man page. Every time a program does not want to start for whatever reason, run 'ldd' to see if all needed libraries are installed and are version compatible. Run 'ldd' on both computers to see where the differences are.

'ldd' should be installed on a system if you have loaded compilers and such like but just in case it's not in Fedora its provided by the glibc-common package.

Good luck


Alwin
Reply With Quote
  #5  
Old 17th July 2010, 07:48 AM
arifwn's Avatar
arifwn Offline
Registered User
 
Join Date: Jul 2010
Posts: 12
linuxchrome
Re: total newb

Try to statically link your program so it can run on any distro regardless of library's availability.
Reply With Quote
  #6  
Old 14th August 2010, 01:50 PM
tux4me's Avatar
tux4me Offline
Registered User
 
Join Date: Nov 2008
Location: Denmark
Posts: 68
linuxfedorafirefox
Re: total newb

That is exactly how i would do it too.
When you compile statically, all needed libraries get included in your executable.
You get a bigger binary, a lot bigger, (compared) but it runs faster and is more portable.
But you have to recompile it every time the libs gets updated, if you want to use the new libs.
Reply With Quote
Reply

Tags
newb, total

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Total Newb questions...Fedora 12 Kalthia Servers & Networking 6 24th April 2010 01:42 PM
A total newb... and pulseaudio problems That Lame Thing Using Fedora 12 9th January 2010 06:35 PM
Total newb. no GUI calavera Installation and Live Media 4 29th September 2006 02:44 AM
C++ Compiler total NEWB! rambone Installation and Live Media 7 30th January 2006 02:10 AM
Total Newb Question Nezmin2 Using Fedora 1 19th October 2005 10:33 PM


Current GMT-time: 08:50 (Friday, 24-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat