15

I was wondering about generic installations of all applications in linux. And what that means? Well, when I was using windows I knew that if I want to install an application I am double-clicking the .exe file and then next,next,next.

In linux, I have understood that maybe there is a common (not generic) way to install any application. Installing from source maybe? Well is there any step by step method that can be used to install application like in windows or not?

I am asking because I do not want to keep asking the google, how to? So, I have managed to install recently from source freecad from this guide and I think that it would be a very nice start as common method, right?

But the thing then is where to find the right source and when an application has a very unique method of installation!

Radu Rădeanu
  • 169,590
gabriel
  • 1,076

5 Answers5

16

Installation instructions vary across programs although there are well-established tools like autotools (includes automake and autoconf) and cmake.

Since programs can come in different programming languages, its hard to give generic commands that suit all packages. For example, Python often have setup.py scripts where C programs often use autotools or at least a Makefile.

I always start with finding the INSTALL, README or similar files. If you need to compile a program from source, you likely need the build-essential package which depends on compilers and other generic development packages.

Depending on the program you're trying to compile, you might need to install other dependencies. Check the README for that or the output of the ./configure script (an executable file located in the root of the extracted source). For example, if it says that you need "x11 development headers", try finding "x11-dev" or "libx11-dev" in the repositories (in this case, it's libx11-dev what you're looking for).

Source distributions that were built with autoconf/automake can be extracted and configured with:

tar xf foo-1.0.tar.gz
cd foo-1.0
./configure
make
sudo make install

Use ./configure --help for available options. By default, the files are often installed to /usr/local which is perfectly fine. Unless you're going to package the file into a .deb file, do not change this prefix to /usr as it may conflict with the package management system (dpkg).

make is supposed to start compiling everything where make install installs the files to the designated locations (sudo is necessary for writing to privileged locations like /usr/local). To uninstall it later, run from the source directory sudo make uninstall (providing that the package is properly build with autoconf/automake, which is a responsibility of the developer, not you, the user!

If you're just interested in compiling a package from the software center on your computer, proceed with (replace package and the version accordingly):

sudo apt-get build-dep package
apt-get source package
cd package-1.0
dpkg-buildpackage -b -uc -us

See the respecxtive manual pages for more details on the commands. (e.g. run man dpkg-buildpackage in a terminal). After performing these commands, you'll have a .deb file in the parent directory. It's recommended to use the packages from Ubuntu repositories where possible. The above steps are shown for educational reasons, but generally you want to make a modification to some files before building the package.

Lekensteyn
  • 174,277
  • Very helpfull indeed, So the only common method is downloading the package ( tar??) and then extract to see its contents!Later on i have to ask, i am extracting the files and then i am running all those commands you mentioned above.So the install file is the one i was working all those commands?Or all the application files-directories are specific either installing from center or installing from source?To make it clear, I just want to install the application whereever i want all in /opt or /usr?Thanks – gabriel Apr 18 '12 at 09:57
  • See updated post. Extract & change directory is 99% of all cases. You may see varying extensions after .tar, like .gz, .bz2, .xz. These refer to the compression format. .zip is less common as it cannot store file permissions, but it's seen in at least 7-zip. Note: my instructions are more generic ones for "compile from source". The paths and configuration is not the same as the one from the Ubuntu Software Center. – Lekensteyn Apr 18 '12 at 10:09
  • So,does not matter in which directory i am working with ./configure , make and make install.For example id i download and extract in the home directory then i should run these commands and automatically the make install command will place the installation files in a specific directory right? – gabriel Apr 18 '12 at 10:15
  • There is not , so , a specific directory like windows "Program Files", right? – gabriel Apr 18 '12 at 10:15
  • After extractring the tarball, change your directory to the extracted directory. The exact location does not matter, you can do it in your home directory or ~/Downloads, just be sure that the path does not contain whitespace as it breaks most tools. For example, ~/Downloaded Sources is a bad idea where ~/Downloaded-sources is perfectly fine. For your last question, see http://askubuntu.com/q/27213/6969 – Lekensteyn Apr 18 '12 at 10:17
  • Ok, so i run the commands in the directory i extracted and then what?Am i able to point where i want to install or the installation files are just splitted in the directories the other post points?thanks – gabriel Apr 18 '12 at 10:51
  • You can test it yourself, instead of running sudo make install, use make install DESTDIR=/tmp/fs. Then run find /tmp/fs -ls to find out what files are installed in which directory (assuming that the program uses autotools) – Lekensteyn Apr 18 '12 at 13:21
  • Might be nice to mention checkinstall so you can install from source as a package. – Callum Rogers Apr 18 '12 at 13:54
  • I haven't used checkinstall before so I cannot speak for it. Building .deb packages using debuild/dpkg-buildpackage is more convenient. – Lekensteyn Apr 18 '12 at 15:35
  • checkinstall is for when you have a source tree that hasn't been debianized. It can monitor the install and create a .deb from that, which is fine as long as you don't need to specify any conffiles or run any postinst scripts. – Scott Severance Apr 18 '12 at 23:23
7

FreeCAD is available in the Ubuntu Software Center, so it was not necessary to build and install it from source code.

The Ubuntu Software Center always the first place where you should look. Installing is just a matter of clicking a button.

There's an icon for the Ubuntu Software Center in the bar on the left side of the screen.

If you really want to build and install a program from source, then look for a README file or other instructions that come with the program.

Many software packages use GNU autotools as the build system and can be built and installed with the following commands:

./configure
make
sudo make install

Before building a program you'll need to check what the required libraries and other dependencies are (that should also be mentioned in the documentation for the program). On packages.ubuntu.com you can find the Ubuntu packages that contain the required libraries.

Suppose the program needs a library called blah, then you'll probably need to install the package libblah-dev (lookup the exact name on the Ubuntu Packages page I mentioned above).

sudo apt-get install libblah-dev
Jesper
  • 2,227
  • HAHA,yeah i know this icon!BUT if YOU have ever noticed there is a description in software center in any application that says "canonical does not provide critical updates" and the freecad version was the 0.8 and i installed freecad v0.13.I just want a deeper knowledge in linux systems not answers pointing where is the software center,thanks anyway!:-) – gabriel Apr 18 '12 at 09:43
  • NOW you talk right!And thank you VERY much,that is the deeper knowledge i just want!Continue! – gabriel Apr 18 '12 at 09:45
  • OK,So if i want to install application from source this application's people must provide the source code?For example, if i want to install a commercial application i am not able to install from source right?THIS is the opensource project anyway right?That the applications have the source open for everyone but commercial dont.Right? – gabriel Apr 18 '12 at 09:51
  • "if i want to install application from source this application's people must provide the source code?" - Yes ofcourse, that's what "from source" means! And if it's a commercial program that is not open source, then you don't get the source code. – Jesper Apr 18 '12 at 09:58
  • So that's why most of windows apps are not installable in linux right? – gabriel Apr 18 '12 at 10:03
  • Most software is written to work on a specific OS. A program written for Windows does not work on Linux, in fact, even if you have the source code then you can't even compile it to work on Linux, because the functions of the OS are not the same. – Jesper Apr 18 '12 at 10:53
  • Nice,so the open source why is not only for linux?There are versions for windows OR linux OR mac etc right?So, if i buy for example a program from a company i will not be able to run it in linux right?Even i have all the necessary knowledge?thanks – gabriel Apr 18 '12 at 10:56
  • Yes, there's also open source software for Windows, Mac etc. Most commercial software is not open source, and you cannot run it on any other operating system than what it was made for. There are things like Wine that can make Windows software run on Linux, but this is limited; not all software works with it. – Jesper Apr 18 '12 at 10:59
  • @gabriel Program made for windows is not compatible with linux, same way that program can not be installed in osx and vice verse. Windows application doesn't mean it is closed source and that's why can't be installed in linux. The chormium project (Google chorme based on it) is open sourced and you can see the code and compile for windows.In linux there can closed source program like nvidia drivers,flash etc. Then you ask why in linux compile from source is preferable some time? it is because there too many variants for linux and most common method would be compile for yourself. – Web-E Apr 18 '12 at 11:06
  • Ok, thank you very much!I will not ask in this post about wine but if you can help me in an other post of me it would be great! – gabriel Apr 18 '12 at 11:07
  • http://askubuntu.com/questions/121528/autocad-on-linux-ubuntu-11-10 – gabriel Apr 18 '12 at 11:07
  • It is actually possible to write programs that work on both Windows and Linux. An example hello world program for the console can use the same code on both OSs. On Windows, other library functions are recommended though. Even if you don't use the POSIX standard library functions, you can use cross-platform libraries (such as GLib or GTK) that takes the system-specific details away and provides you a more abstract programming layer. – Lekensteyn Apr 18 '12 at 13:20
2

There are only two basic approaches:

  1. Use the Software Center or a related tool (Synaptic, apt-get, etc.). This is normally the best option. Going outside this method can lead to problems, such as conlficts and difficulties with updates, so you should only do something elseif you know what you're doing.
  2. Read the documentation and use it to install. You might find it on the project's website, or in the tarball, or from the place you got your file. Or, there might be no documentation, in which case you have to Google or guess. There are very many different ways to install software. If this gets confusing, go back to number 1.

    If your package uses the standard ./configure; make; sudo make install, you can use checkinstall to get a .deb of what you built. That way, you don't have to sacrifice package management.

  • Ok i asked this question because i had some problems with software center and .deb files.For example i wanted to install draftsight , a cad program and it is for 32 bit only.So i tried with the ignore dependencies and architecture commands but nothing came on.So is the extraction of a .deb file for example possible an then a manual installation with make and sudo make etc?thanks – gabriel Apr 18 '12 at 11:02
  • If there's no .deb available for your architecture, then you'll have to install your program another way. You can Google for how other people have done it, or search for a .dev with the proper arch, or build from source. See my upcoming edit for something important. – Scott Severance Apr 18 '12 at 11:06
  • checkinstall before we run those commands?and what, a .deb is appeared?((i have to ask how do you make your posts look nice and organized?with commands highlighted and staff?any guide for askubuntu?))So i can extract a .deb then checkinstall and make it run on 64bit for example or am i wrong and stupid with this question? – gabriel Apr 18 '12 at 11:17
  • You can't use checkinstall on existing .deb packages. If you have a .deb already, technically you can extract it and install manually, but that's not the best way. checkinstall is for when you build from source. For formatting help, see the help link that always appears when posting. – Scott Severance Apr 18 '12 at 23:21
  • So, the .deb file with an architecture different than 64bit that i have, should not be extracted and then installed manually?And when you say "is for when you build from source." the .deb file is build from where?Does it use the same source code as you build from source?Silly question? – gabriel Apr 19 '12 at 07:32
  • The .deb file is built from source. apt-get source .... But you've been talking all along about getting a program's source code. That's what I'm talking about. You should treat a .deb as an opaque file that you can't do anything with except install it. – Scott Severance Apr 19 '12 at 10:55
0

Installing from source is very difficult to support.

Whenever possible, install from software center. That is the equivalent of the windows next->next->finish mentality.

You can install things from source on windows too. That's not unique to linux, it's just that more source available applications target linux.

RobotHumans
  • 29,530
  • 1
    well, i just want to jump in my linux experience i am three years now and what i want is finally not to keep asking how to and how to,do you feel me?Just to make my linux knowledge deeper and deeper.Why dont you explain to me the source etc? – gabriel Apr 18 '12 at 09:32
  • http://www.linuxfromscratch.org/ – RobotHumans Apr 18 '12 at 09:32
  • Also when an application has no .deb in my ubuntu how to install from software center?Then i am ready AGAIN to ask in askubuntu.com or google.gr '''how to install THIS in ubuntu 11.10?''' – gabriel Apr 18 '12 at 09:33
  • Yes. Application specific is better. They produce targeted reproducible answers for specific users. Hence they are useful. – RobotHumans Apr 18 '12 at 09:34
  • Well, that is very helpfull indeed.You just feel me and gave me what i just want.BUT i would like to ask you after much much reading about linux and linux will i never be able to install ANY application in linux systems?OR something like this is not possible in any way? – gabriel Apr 18 '12 at 09:37
0

Ubuntu offers a variety of installation methods

  1. Via centralised packaging system

    This is the preferd method in ubuntu (but personally I don't like it) software-centre ,synaptic, and aptitude are examble for it

  2. Standalone deb package:- This method is simpler as in the case of windows ,just double click the file and press install button Eg:Gdebi package manager

  3. binary software: these are very similar to windows .exe installation, It offers variety of gui for Installer, These are usually .bin files

    you can use bit rock or similar tools to make such packaes

  4. autopackage and similar tools :-these are third party package managers created to support various linux distros

  5. source code:this is the first method in the software installation ,In this method the source code is converted into the binary executables ,Installtions instructions for these softwares are usually attached with source code, And these are valid for open source s/w only

Warning:-These are my observation only ,I am a newbie in linux ,So fell free to edit/downvote If there is anything wrong

Tachyons
  • 17,281
  • Well thanks, From my experience i usually see in software center the description of an app and if the canonical provides updates then i install it from center.If not i am googling so that is why i posted this question, and all the answers were ver helpfull.Thanks – gabriel Apr 18 '12 at 10:48
  • Option 1 is far better than 3 and 4, because you can get updates automatically. Option 2 is fine when the package or version you want isn't in your repository (option 1). Avoid numbers 3 and 4 if at all possible because they don't take advantage of all the wonderfull benefits of package management and can result in conflicts down the road. Even though Autopackage does its own package management, it's still a separate system and has the potential for conflicts and stuff going out of date. And, unless you're a programmer, try to avoid building for source. Package management is a wonderful thing! – Scott Severance Apr 18 '12 at 11:04
  • I prefer these methods only because my internet connection is sloooow :p – Tachyons Apr 18 '12 at 11:09