LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-01-2012, 01:26 AM   #1
Ztcoracat
LQ Guru
 
Registered: Dec 2011
Distribution: Slackware, MX 18
Posts: 9,484
Blog Entries: 15

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Compiling programs from source


Hi:

I have never compiled from source and did not know how to so I went to the tutorials in our forum and looked under App's/ Gui/ Multimedia.
I found the article "Compiling Programs from Source" By: Jeremy and read it twice.

http://www.linuxquestions.org/linux/...ms_from_Source

The article is clear that I will need a compiler (gcc)
Do I need to go and get gcc or did my distro (Debian)come with it?

Also that when I do download from source to put the source in the following directory /usr/local/src
And than to change the directory after the unzip and the untar but what directory would I change to?

When needing the apropriate libraries; how do I know or how can I tell which libraries I'll need?

I am trying to learn first before I begin to compile and verify anything in the terminal and don't think it's wise to just download any random programs/.tar.gz-

Please advise
 
Old 10-01-2012, 01:55 AM   #2
JaseP
Senior Member
 
Registered: Jun 2002
Location: Eastern PA, USA
Distribution: K/Ubuntu 18.04-14.04, Scientific Linux 6.3-6.4, Android-x86, Pretty much all distros at one point...
Posts: 1,802

Rep: Reputation: 157Reputation: 157
Your distro will undoubtedly include gcc...

Just make sure that gcc and the make tools are all installed... There's tons of packages for gcc,... I would just install the metapackage for gcc at first and then determine if you need more...

You also want to install the headers for your kernel and (probably) the backports... and maybe the gcc tools for other architectures, depending on your target architecture...
 
Old 10-01-2012, 01:59 AM   #3
nugat
Member
 
Registered: Sep 2012
Posts: 122

Rep: Reputation: 31
Quote:
Originally Posted by Ztcoracat View Post
The article is clear that I will need a compiler (gcc)
Do I need to go and get gcc or did my distro (Debian)come with it?
It is in the default software sources, if it is not there already. Use the "apt-get" program to install gcc and other dev tools, e.g.:
Code:
apt-get install build-essential
then you can check the version of installed gcc:

Code:
gcc -v
Quote:
Also that when I do download from source to put the source in the following directory /usr/local/src
And than to change the directory after the unzip and the untar but what directory would I change to?
that depends on the tarball directory structure. you can use the -v flag to show what is being done when you uncompress, e.g.:

Code:
tar zxvf foo-0.99.tar.gz
a popular convention is to use the same name in the tarball as is the directory you tar up - typically the name of the program, plus the version. so in the above case, you might do:
Code:
cd foo-0.99
but this is by no means a rule. use the -v flag to see what tar is decompressing. you can also use "t" instead of "x" in the tar command, to just show the contents of the tarball, w/o extracting, e.g.:

Code:
tar ztvf foo-0.99.tar.gz
Quote:
When needing the apropriate libraries; how do I know or how can I tell which libraries I'll need?
Typically, the source you wish to compile will have an INSTALL and/or README (and possible doc/ files) which should outline any libraries and header files required to build the program. You will quickly encounter missing libs/headers when you run ./configure. Or possibly during the subsequent make.
 
Old 10-01-2012, 02:11 AM   #4
Ztcoracat
LQ Guru
 
Registered: Dec 2011
Distribution: Slackware, MX 18
Posts: 9,484

Original Poster
Blog Entries: 15

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Thanks JaseP

I'll have to learn more about the make tools and the metapackages-
Of course I won't use this because it's for Ubuntu but I'm using this in the Code brackets as an example so I know what I'm looking at-

Is this what a metapackage looks like?

Code:
Format: 1.8
Date: Fri, 28 Sep 2012 11:50:48 +0100
Source: ubuntu-meta
Binary: ubuntu-minimal ubuntu-standard ubuntu-desktop
Architecture: powerpc
Version: 1.285
Distribution: quantal
Urgency: low
Maintainer: Ubuntu/powerpc Build Daemon <buildd@ross.buildd>
Changed-By: Colin Watson <cjwatson@ubuntu.com>
Description: 
 ubuntu-desktop - The Ubuntu desktop system
 ubuntu-minimal - Minimal core of Ubuntu
 ubuntu-standard - The Ubuntu standard system
Changes: 
 ubuntu-meta (1.285) quantal; urgency=low
 .
   * Refreshed dependencies
   * Added python3 to minimal
   * Added python3-minimal to minimal
   * Removed python from minimal
   * Removed python-minimal from minimal
Checksums-Sha1: 
 e760ed58d2f216f043329d08c09eefd95b3b6ed3 2876 ubuntu-minimal_1.285_powerpc.deb
 5dbbcdbf282242fbdfb85ed527d5a41cf02c59cf 2896 ubuntu-standard_1.285_powerpc.deb
 4439d1c7fb50153b246ee42c2e4d364b183eec8e 3898 ubuntu-desktop_1.285_powerpc.deb
Checksums-Sha256: 
 47bb4206cb8f00c7a0907a926d05cb3cda4efaa380d3f8da84f355711847d443 2876 ubuntu-minimal_1.285_powerpc.deb
 ca164e6308f2d788a3d466a3785aff3689b43dd90ff6695597c22b178217247a 2896 ubuntu-standard_1.285_powerpc.deb
 3d3bd382624e6a21d21f19c2a3e83d441229b47c243bf87dad4f0a9f3be3d40c 3898 ubuntu-desktop_1.285_powerpc.deb
Files: 
 93197ffd8aab49da0ad536672d569d48 2876 metapackages optional ubuntu-minimal_1.285_powerpc.deb
 27990cb1a4defbfa70cc93e67988fd6f 2896 metapackages optional ubuntu-standard_1.285_powerpc.deb
 98641a9d8c064d8a94b7e60d4fb316d1 3898 metapackages optional ubuntu-desktop_1.285_powerpc.deb
I'll look for other tools for other architectures like you said-
 
Old 10-01-2012, 02:26 AM   #5
Ztcoracat
LQ Guru
 
Registered: Dec 2011
Distribution: Slackware, MX 18
Posts: 9,484

Original Poster
Blog Entries: 15

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Nugat:

I'll check in my Software Sources if not I'll use the command you posted. Thanks

I didn't know about -v flag to show whats being done when I umcompress-

I'll read the 'Install or 'Read Me'
Thanks for the heads up on if I do encounter a problem. When I run ./configure it should show me what's missing if anything.

This is just an example (lib44jd) but I think I got it-
Code:
tar zxf lib44jd.tar.gz
cd lib44jd
./configure
make
make test (optional)
make install
Right?
 
Old 10-01-2012, 02:33 AM   #6
nugat
Member
 
Registered: Sep 2012
Posts: 122

Rep: Reputation: 31
Quote:
Originally Posted by Ztcoracat View Post
Nugat:

I'll check in my Software Sources if not I'll use the command you posted. Thanks

I didn't know about -v flag to show whats being done when I umcompress-

I'll read the 'Install or 'Read Me'
Thanks for the heads up on if I do encounter a problem. When I run ./configure it should show me what's missing if anything.

This is just an example (lib44jd) but I think I got it-
Code:
tar zxf lib44jd.tar.gz
cd lib44jd
./configure
make
make test (optional)
make install
Right?
Wel, for a generic example, yes that is about right. Note that there are typically a lot of options you can pass to the configure script (like --prefix=/opt, for example). you might also need to be root for the "make install" command (if not root already). you could use su/sudo for that step.
 
Old 10-01-2012, 02:34 AM   #7
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,830

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
yes, you are right. ./configure will tell you if anything missed. In general when you want to build a software you need to install all the dependencies, and it is usually documented.
 
Old 10-01-2012, 02:52 AM   #8
Ztcoracat
LQ Guru
 
Registered: Dec 2011
Distribution: Slackware, MX 18
Posts: 9,484

Original Poster
Blog Entries: 15

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Nugat:
I found in that article that the last step needs to be executed with root permissions.
Until I read I didn't know in the last step it copies the compiled programs to my system.


Pan64
I want to make sure I understand.
You said that I need to install all the dependencies and it's usually documented.
Documented in the "Read Me" file or the "Install" file you mean?

Or documented at the Debian website where I obtain the .tar.gz?
 
Old 10-01-2012, 03:14 AM   #9
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,830

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
let we say you want to build from source "thisapp". You will need to go to the home page of "thisapp" and read the online documentation. You will find some info about dependencies: to be able to compile you need to have installed "thatapp" (also there can be a readme or howto about it). Usually it means there is a package named thatapp-devel. All those packages should be installed first. ./configure will report missing packages too, but sometimes it is not really trivial.
To install anything (including your own software) you need to use root. To build your software you must not use root.
 
Old 10-01-2012, 03:23 AM   #10
nugat
Member
 
Registered: Sep 2012
Posts: 122

Rep: Reputation: 31
Quote:
Originally Posted by pan64 View Post
To install anything (including your own software) you need to use root.
unless of course, you are willing to modify PATH, LD_LIBRARY_PREFIX, etc.
Quote:
To build your software you must not use root.
show of hands...who does this? (me)
 
Old 10-01-2012, 03:29 AM   #11
Ztcoracat
LQ Guru
 
Registered: Dec 2011
Distribution: Slackware, MX 18
Posts: 9,484

Original Poster
Blog Entries: 15

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Thank You Pan64

I understand now; thanks for the confirmation about being root and when I must not use root.

I'm off to do a little more reading and learn more about these things:
make tools, install headers for my kernel, and metapackages for gcc.

Until I know more and am certain of how this(compiling from source)process should progress I won't proceed with the process. I'm sure you'll agree one must know and fully understand all of the details.
 
Old 10-01-2012, 03:31 AM   #12
Ztcoracat
LQ Guru
 
Registered: Dec 2011
Distribution: Slackware, MX 18
Posts: 9,484

Original Poster
Blog Entries: 15

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Quote:
Originally Posted by nugat View Post
unless of course, you are willing to modify PATH, LD_LIBRARY_PREFIX, etc.
show of hands...who does this? (me)
I'm not sure if modifying would be a good practice for the first time compiling from source.
 
Old 10-01-2012, 03:48 AM   #13
nugat
Member
 
Registered: Sep 2012
Posts: 122

Rep: Reputation: 31
Quote:
Originally Posted by Ztcoracat View Post
I'm not sure if modifying would be a good practice for the first time compiling from source.
oh, i wasn't talking about modifying the source software. i just meant you could do something like this:
Code:
./configure --prefix=$HOME/myapp
make
make install
and then add something like this to your ~/.bashrc
Code:
myapp=$HOME/myapp
if [ -d $myapp/bin ]; then
  echo $PATH|grep -q $myapp/bin && : || export PATH=${myapp}/bin:${PATH}
fi
if [ -d $myapp/lib ]; then
  echo $LD_LIBRARY_PATH|grep -q $myapp/lib && : || export LD_LIBRARY_PATH=${myapp}/lib:${LD_LIBRARY_PATH}
fi
that way you could install software to your home directory (if you really wanted to), and the binaries would be in your path and the path to the libraries would be found by the binaries (per the .bashrc stuff).

it is not how one would normally install software, it is just a way to install it w/o using root.

Last edited by nugat; 10-01-2012 at 03:49 AM. Reason: typo
 
Old 10-01-2012, 04:10 AM   #14
JaseP
Senior Member
 
Registered: Jun 2002
Location: Eastern PA, USA
Distribution: K/Ubuntu 18.04-14.04, Scientific Linux 6.3-6.4, Android-x86, Pretty much all distros at one point...
Posts: 1,802

Rep: Reputation: 157Reputation: 157
Metapackages are, basically, just packages that assemble other packages together, under a big umbrella. That way you get the essential packages you need to do 90% of what falls out there...

For Debian based distros, you should probably be using apt-get install [name of the package] or Synaptic.
... Just FYI...
 
Old 10-01-2012, 04:31 AM   #15
Ztcoracat
LQ Guru
 
Registered: Dec 2011
Distribution: Slackware, MX 18
Posts: 9,484

Original Poster
Blog Entries: 15

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Nugat:

Ok, I get it. Thanks for the example :
my app= $HOME/myapp
if [ -d $myapp/bin]; (still learning shell scripting)

I might consider installing to my home directory; but not for the first try.(nervous)
Thanks for showing me a way to install w/o using root

Anyway, that tutorial mentions a noteable exception of a Perl program or Cpan,so in order to complete this compile from source do I need to install Perl or Cpan?
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
DISCUSSION: Compiling Programs from Source jeremy LinuxAnswers Discussion 52 03-02-2024 12:26 PM
compiling programs from source Frank Leone Linux - Newbie 3 10-30-2005 01:47 AM
why is compiling source programs under linux such a headache? guy24x Linux - Software 21 07-28-2005 06:04 AM
Compiling Programs from Source-help orisma Linux - Newbie 6 03-03-2005 07:57 AM
Compiling programs from source rpms coolfrog Linux - General 1 09-10-2004 03:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:35 AM.

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