LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 04-10-2007, 01:59 AM   #1
spaaarky21
Member
 
Registered: Jun 2004
Location: Omaha, NE
Distribution: Ubuntu 7, Fedora Core 4
Posts: 192

Rep: Reputation: 30
Making a distributeable binary?


How can I compile a C++ application using GCC so that the binary can be run on multiple Linux distribution? Depending on where I am compiling and where I am running, I get runtime errors about the libc .o file, or files. When I compile code on Linux, the binary is always so small compared to a binary on other systems like Windows or Mac but it looks like that is because very little is being linked into it. Is it possible to link "basic" C/C++ language libraries into the binary? Certain binary-only closed-source programs (like Id Software games for example) seem to function properly across distributions. Sorry if I am missing some fundamental aspect of the Linux architecture. If someone could explain it, I would certainly appreciate it.

-Brandon R

Last edited by spaaarky21; 04-10-2007 at 02:02 AM.
 
Old 04-10-2007, 02:35 AM   #2
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
You need to statically link the libraries or add code that makes sure the libraries are present before it tries to run, and takes appropriate action.

gcc usues dynamic linking by default - which is why the binaries are so small compared with those proprietary OS's. It is also the reason for "dependency hell" you may have experienced with rpm installations, and the extensive use of package managers like yum.

Usually, you would want to set up yum, and apt, compatible packages to distribute your software widely. If lots of folk find your work useful, then this will take on a life of its own.

It is not, however, possible to guarantee it will work with every linux distribution possible. There are just too many variables.
 
Old 04-10-2007, 07:48 AM   #3
spaaarky21
Member
 
Registered: Jun 2004
Location: Omaha, NE
Distribution: Ubuntu 7, Fedora Core 4
Posts: 192

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by Simon Bridge
You need to statically link the libraries or add code that makes sure the libraries are present before it tries to run, and takes appropriate action.

gcc usues dynamic linking by default - which is why the binaries are so small compared with those proprietary OS's. It is also the reason for "dependency hell" you may have experienced with rpm installations, and the extensive use of package managers like yum.
Dependency hell is the reason I had to upgrade to Fedora Core 4 instead of just upgrading MySQL.

Well, I think static linking will do. I did some searching before I posted but wasn't looking with the right words. Apparently GCC's -static flag should be just about all I need. I don't plan on distributing packages far and wide, just running off of a flash drive on multiple distros, so this should be the best option.
 
  


Reply



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
LXer: To binary or not to binary, that is the question LXer Syndicated Linux News 0 12-31-2006 09:33 AM
Do I need binary 1 and binary 2 dvd iso for base install? salah-ad-din Debian 5 08-15-2006 04:43 PM
using LFS can we produce re distributeable linux os ravikumarG Linux From Scratch 5 04-04-2005 02:52 PM
Binary IO arvind_tyche Programming 3 05-03-2004 11:11 AM
Binary Puzzle aioss Linux - Software 0 02-07-2004 01:44 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:58 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
Open Source Consulting | Domain Registration