86

Moving from Windows to Linux, I am unable to understand the process of installing software in Linux. In Windows, when we run an installation file, it asks where you wish to install the program, most probably in program files folder only. Later, it edits the registry. This is called installation in Windows. What does 'installing software' in Linux mean exactly?

Suppose I downloaded source code, configure it, and then build the binary using make. Now it is just a binary, not a usable program yet. How is it going get 'installed' ? By make install ? And what does this command do, exactly?

1

5 Answers 5

74

Make is a general purpose workflow program, usually used for compilation. But it can be used for anything.

When you do something like "make all", the make program executes a rule named "all" from a file in current directory named "Makefile". This rule usually calls the compiler to compile some source code into binaries.

When you do "make install", the make program takes the binaries from the previous step and copies them into some appropriate locations so that they can be accessed. Unlike on Windows, installation just requires copying some libraries and executables and there is no registry requirement as such. In short, "make install" just copies compiled files into appropriate locations.

3
  • 8
    Technically, the registry is not a requirement - what all installers add is just a convenience function, much like the package manager database in Linux, for people who like being able to uninstall software. Nov 22, 2011 at 8:45
  • 2
    @grawity Actually, in Windows it is required to edit the registry for many reasons, such as integration. In Linux, integrating softwares to one another usually just involves copying files or adding lines to config files by something like a post-install script. Aug 20, 2013 at 20:54
  • 1
    @sharjeel It would be helpful to tell how I can find the rule named all in the Makefile and what the end marker of that section looks like, so I can see where rule processing for all stops.
    – Pro Backup
    Oct 26, 2016 at 15:14
53

make install does whatever the Makefile author wants it to do. Typically, by this point, it is too late to change the install directory, as it is often known earlier, during the build, so help files and configuration files can be referenced with the correct pathnames.

Many projects use the GNU Autotools to try to improve their portability among hardware and operating system differences. (Different Unix variants use slightly different headers for declarations of functions that are slightly off the usual path -- except most programs need one or another of the ones declared in different locations.)

When a project does use the Autotools, the normal mantra to install it is:

./configure
make
make install

The ./configure typically allows you to use a command line option like --prefix /opt/apache or something similar to specify a different pathname. /usr/local/ is a common default prefix. It is far easier for locally built software to live in one place and distribution-provided software to live in the "main directories": /usr/ /bin/, and so on. (Packagers are very careful to never touch files in /usr/local/ -- they know it is exclusively for system administrators.)

Anyway, the ./configure --prefix /path/to/new/prefix will set a variable in the Makefile that is available when compiling the program, modifying the manual pages so they point to the correct locations for files, modifying configuration files, etc. So make will build the software specifically for the install location you want and make install will install it into that location.

Most programs can run even without the final make install step -- just ./program_name will often start them up. This is definitely a per-project thing -- some, like postfix, qmail, etc., are made up of many different moving pieces and rely on them all working together. Others, like ls or su might be self-contained enough to execute fine from the directory they were built in. (This is not often useful -- but sometimes very useful.)

However, not all projects use the Autotools -- they are huge, complicated, and miserable to maintain. Hand-written Makefiles are much simpler to write, and I personally think just distributing a simple Makefile with configuration variables available is a lot easier on developers and users both. (Though the ./configure ; make ; make install mantra is really easy on users when it works.)

24

make install does nothing less then executing the install function / section in your Makefile

3
  • 1
    Right, it just likes make clean, basically it just executes the codes under the section.
    – Kyung Lee
    Feb 1, 2019 at 7:17
  • 1
    "does nothing more"?
    – Inego
    Dec 2, 2019 at 6:26
  • My makefile does not have an install function yet calling sudo make install causes my binary to get moved from the build directory to /usr/local/bin. How is that? Nov 19, 2022 at 15:41
10

Most important thing to mention regarding installing software on Linux is that it's much more reliable and easy to install software from your distribution (this is it's purpose!). Only use make install if there's no other way (consider alternate programs as well).

Common mistake of Windows users is to download programs from different places and try to install them, forgetting to check out their distribution packages, which could be installed with a single click or command (in the package manager).

Also remember that one of the main reason for absence of virus infections on Linux is that software is (or should be) installed from central (trusted) location instead of the many random sites.

As an additional note, while distributions like Ubuntu always contain outdated packages, there are also distributions like Arch Linux that are always up-to-date (though they don't offer literally every program ever released for Linux, like Debian/Ubuntu).

As for what exactly would happen when you use package manager, well it would check dependencies, download packages, unpack, put all files to their appropriate directories, according to FHS and distribution's own guidelines, and some other routines which you could probably find out about from the man page of the package manager.

0
0

Using bin_PROGRAMS program, make install puts binary files in /usr/local/bin. When installing linux system, all executable files the system can run will be put in /usr/bin. All the user installed executables will be put in /usr/local/bin by command 'make install'

1
  • 2
    Welcome to Super User! Before answering an old question having an accepted answer (look for green ✓) as well as other answers ensure your answer adds something new or is otherwise helpful in relation to them. Here is a guide on How to Answer. There is also tour for the site tour, and help center for the help center. Dec 24, 2020 at 12:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .