Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

This is an issue that really limits my enjoyment of Linux. If the application isn't on a repository or if it doesn't have an installer script, then I really struggle where and how to install an application from source.

Comparatively to Windows, it's easy. You're (pretty much) required to use an installer application that does all of the work in a Wizard. With Linux... not so much.

So, do you have any tips or instructions on this or are there any websites that explicitly explain how, why and where to install Linux programs from source?

share|improve this question
4  
"Comparatively to Windows, it's easy. You're (pretty much) required to use an installer application that does all of the work in a Wizard. With Linux... not so much." There's the weak point in the question. With Windows, you rarely get the source code, so you're at the mercy of whomever made the package. If you think about this, it's not that much different from saying "there was no Linux package, so I have to build from source", ie. there wasn't a way to get it to begin with. Building from source is usually a last resort in *nix-land, but rarely an option in Windows-ville. –  Avery Payne Aug 12 '10 at 1:22
    
That being said... +1 bump for asking a common question that should be answered for all newcomers to *nix systems. :) Building from source sometimes means the difference between fixing a nasty bug and just suffering until the next software release. It's really not that bad, and as many here have pointed out, once you know what to look for and how to do it, fairly painless. –  Avery Payne Aug 12 '10 at 1:24
add comment

5 Answers

up vote 12 down vote accepted

Normally, the project will have a website with instructions for how to build and install it. Google for that first.

For the most part you will do either:

  1. Download a tarball (tar.gz or tar.bz2 file), which is a release of a specific version of the source code
  2. Extract the tarball with a command like tar zxvf myapp.tar.gz for a gzipped tarball or tar jxvf myapp.tar.bz2 for a bzipped tarball
  3. cd into the directory created above
  4. run ./configure && make && sudo make install

Or:

  1. Use git or svn or whatever to pull the latest source code from their official source repository
  2. cd into the directory created above
  3. run ./autogen.sh && make && sudo make install

Both configure and autogen.sh will accept a --prefix argument to specify where the software is installed. I recommend checking out http://unix.stackexchange.com/questions/30/where-should-i-put-software-i-compile-myself for advice on the best place to install custom-built software.

share|improve this answer
    
Why is autogen.sh used when getting the latest, but configure/make is used for an official release? –  Louis Salin Aug 10 '10 at 23:55
1  
Typically people who want the "bleeding edge" software will pull the release from the version control software (like git, subversion, or CVS). This is "bleeding edge" because it's probably untested, unlike a released tarball, which has (probably) been vouched for as working (at least mostly). Make sense? –  Matt Simmons Aug 11 '10 at 2:30
2  
@Matt, sure it makes sense but I think the comment was directed more at the fact that Sandy now made it appear as if there's an autogen.sh in every git'd/svn'd trunk. –  reiche Aug 11 '10 at 10:42
1  
And a chicken in every pot...or something like that. Heck, every once in a while, I come across software without a configure script, too. If there were an easy, unified way of doing it, we wouldn't need packages ;-) –  Matt Simmons Aug 11 '10 at 11:04
    
Matt is absolutely right, this is why I said "for the most part", and first advocated looking up the project's website. The autogen.sh/configure advice will hold for pretty much every GNOME module, and a ton of other projects, too. Some projects don't use automake, and will only have Makefile, and you will just run make && sudo make install. Some Python projects will only have a setup.py, which you will call to install (since there is no real compile setup). There are plenty of other build/install systems out there, too. Hopefully README or INSTALL files will explain exactly what to do. –  Sandy Aug 11 '10 at 13:11
show 2 more comments

I think it's just best to read the documentation coming with that specific program or application that you're wanting to install. Usually there are readmes/READMEs inside the tarballs (the application source archive which you can usually download) or maybe even INSTALL files to read and learn about what is the preferred way of installing said application. In short: RTFM ;)

share|improve this answer
add comment

A summary for using the Ports Collection in FreeBSD:

Find Port

Ports are organized by category so if you don't know what category the port is in you have to find it first:

cd /usr/ports
make search name=myport

Sometimes there are too many entries that way. I personally prefer:

find /usr/ports -name myport* -print -depth 2

Use the * when searching since there are often multiple versions of a port available. The depth argument ensures your return results aren't needlessly cluttered with matches you are unlikely to want.

Configuration

Often, you'll want to do some configuration; software such as Apache and Postgres practically require it. There are three main choices: command line, environment and make configuration files. To get started with the command line:

make showconfig

this will list the default configuration options. If you like the defaults you are ready to compile and install. If not,

make config

will bring up a dialog box where you can select which options you want. (Don't become confused with this and make configure which configures your port with your chosen options!) This is often sufficient but for some software, like Apache, there is often complex configuration that a simple dialog won't handle. For this, you also should look at the Makefile(s) which will sometimes give you some additional targets for make that will give you more information. To continue the Apache example

make show-modules
make show-options
make show-categories

will give you information on setting up you chosen modules, thread options and the like. If your port's defaults are mostly fine and you just want to change a few things, you can also just pass key=value pairs like environment variables:

make MYVBL1=MYVAL1 ... install clean

Also, you can set switch options via the -D option:

make -D MYVAR -D MYOTHERVAR ... install clean

For complex configuration however the command line won't work well and you're better neither of the first two methods will be effective. In this case you can make a configuration file and pass that to make with the __MAKE_CONF variable. FreeBSD has a default configuration file: /etc/make.conf which usually contains information on previously installed ports and other system settings. To begin, create a file with your ports options, call it ~/myport.mk and then combine that file with /etc/make.conf:

cat /etc/make.conf ~/myport.mk >> ~/make.myport.conf

you can then double check your configuration:

make showconfig __MAKE_CONF=~/make.port.conf

and if everything looks good:

make install clean __MAKE_CONF=~/make.myport.conf

BEWARE! If you need to adjust your configuration settings after make configure or an installation in whole or part you absolutely must clear your configuration first:

make rmconfig

Failure to do so will result in unexpected interactions between the ports subsystem, your port's make defaults and your desired configuration.

That's kind of a lot for a summary, but the complexity of configuration is mostly about the app, not the port. Bash for example, doesn't really have any options.

Installation

This is the easy part:

make install clean

or you can

make build
make install
make clean

which is just more typing.

That's pretty much it. Obviously there is more you can do such as recursively listing dependencies and configuration options, update with patches and so on. Here I will refer you to the Ports section of the Handbook, the port subsystem's man page (good info on additional make targets) and the make man page.

share|improve this answer
add comment

I just want to add that there are package managers that compile packages from source, and handle all package dependencies, flags, etc..

In BSD systems it's ports: Using the Ports Collection

In Debian, the apt-get package manager can install from source too: APT HOWTO: Working with source packages (Same goes for Ubuntu, Linux-mint and everything else based on Debian)

The Gentoo distribution uses the portage package manager, which compiles the whole system from source only: Portage Introduction.

Slackware can compile packages but I don't know if there's any package manager for this in there.. =)

Anyway you can always compile packages manually like Sandy mentioned above =) Also it must be possible to use apt-get or portage package managers in any other distro...

share|improve this answer
    
To say "the apt-get package manager can install from source" is incorrect. The quoted section describes how one can create a Debian package from Debian sources. Not arbitrary upstream sources. –  Faheem Mitha Dec 13 '11 at 19:45
add comment

Recently I've started using "Checkinstall" when installing from source outside of my package manager. It builds a "package" from a 3rd party tarball which can then be installed and managed (and uninstalled) through your package manager tools.

Check out this article - http://www.linuxjournal.com/content/using-checkinstall-build-packages-source

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.