特殊:Badtitle/NS100:CompilingEasyHowTo:修订间差异
小无编辑摘要 |
小无编辑摘要 |
||
第4行: | 第4行: | ||
Let's say you are a moderately experienced Linux user, and you want to | Let's say you are a moderately experienced Linux user, and you want to | ||
install an application off the Internet but it doesn't have a nice | install an application off the Internet but it doesn't have a nice | ||
package that works on your system. A lot of users, even quite | package that works on your system. (If it does have a package, install it following the instructions on [[UbuntuHelp:InstallingSoftware|InstallingSoftware]].) | ||
A lot of users, even quite | |||
experienced ones, have issues with going from the tarball to the | experienced ones, have issues with going from the tarball to the | ||
installed program because they just do not know the fairly easy steps | installed program because they just do not know the fairly easy steps | ||
第11行: | 第12行: | ||
developer sites. | developer sites. | ||
=== Step 1: Prep your system for building packages === | === Step 1: Prep your system for building packages === | ||
By default, Ubuntu does not come with the tools required. You need to install the package ''build-essential'' | By default, Ubuntu does not come with the tools required. You need to install the package ''build-essential'' for making the package and ''checkinstall'' for putting it into your package manager. These can be found on the install CD or in the repositories: | ||
<pre><nowiki> | <pre><nowiki> | ||
sudo apt-get install build-essential | sudo apt-get install build-essential checkinstall | ||
</nowiki></pre> | </nowiki></pre> | ||
And since you may want to get code from some projects with no released version, you should install the packages ''cvs and subversion''. | And since you may want to get code from some projects with no released version, you should install the packages ''cvs and subversion''. | ||
第19行: | 第20行: | ||
sudo apt-get install cvs subversion | sudo apt-get install cvs subversion | ||
</nowiki></pre> | </nowiki></pre> | ||
https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=IconNote.png | https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=IconNote.png You may find other packages needed for certain packages. Read any available documentation. | ||
You should then build a common directory for yourself where you'll be building these packages. I recommend creating <code><nowiki>/usr/local/src</nowiki></code>, but really you can put it anywhere you want. Make sure this directory is writable by your primary user account, by running | You should then build a common directory for yourself where you'll be building these packages. I recommend creating <code><nowiki>/usr/local/src</nowiki></code>, but really you can put it anywhere you want. Make sure this directory is writable by your primary user account, by running | ||
<pre><nowiki> | <pre><nowiki> | ||
sudo chown | sudo chown yourusername /usr/local/src | ||
</nowiki></pre> | </nowiki></pre> | ||
and just to be safe | and, just to be safe | ||
<pre><nowiki> | <pre><nowiki> | ||
sudo chmod u+rwx /usr/local/src | sudo chmod u+rwx /usr/local/src | ||
第32行: | 第32行: | ||
=== Step 2: Getting the software you want === | === Step 2: Getting the software you want === | ||
Most of the software you'll generally want comes from released | Most of the software you'll generally want comes from released | ||
tarballs. These are just compressed archives | tarballs. These are just compressed archives with extensions like ''.tar.gz'' or | ||
.tar.bz2 -- they are just like .zip files on Windows or .sit on | ''.tar.bz2'' -- they are just like ''.zip'' files on Windows or ''.sit'' on MacOS X, | ||
if that analogy helps you. If the program you want to install comes in | if that analogy helps you. If the program you want to install comes in | ||
this form, you should | this form, you should move it into the <code><nowiki>/usr/local/src</nowiki></code> | ||
directory we made in | directory we made in Step 1 and extract it by right-clicking on the file and selecting ''Extract Here'', or by using the command line: If your tarball is a .gz, extract the files with the command: | ||
files | |||
<pre><nowiki> | <pre><nowiki> | ||
tar xzvf tarballname.tar.gz | tar xzvf tarballname.tar.gz | ||
</nowiki></pre> | </nowiki></pre> | ||
and for bz2 the similar command | and for bz2 the similar command: | ||
<pre><nowiki> | <pre><nowiki> | ||
tar xjvf tarballname.tar.bz2 | tar xjvf tarballname.tar.bz2 | ||
第48行: | 第47行: | ||
repository, the developers will generally provide instructions on how | repository, the developers will generally provide instructions on how | ||
to do this on their website. If you already installed the packages | to do this on their website. If you already installed the packages | ||
listed on | listed on Step 1, you just need to change to your <code><nowiki>/usr/local/src</nowiki></code> | ||
directory (<code><nowiki>cd /usr/local/src</nowiki></code>) and run the commands that are listed. The procedure will vary | directory (<code><nowiki>cd /usr/local/src</nowiki></code>) and run the commands that are listed. The procedure will vary | ||
from program to program, so I can't help you here but with the given | from program to program, so I can't help you here, but with the given | ||
packages the instructions they | packages the instructions they provide should work smoothly. | ||
=== Step 3: Resolving Dependencies. === | === Step 3: Resolving Dependencies. === | ||
One nice thing about modern Linux distributions is they take care of dependencies for the | One nice thing about modern Linux distributions is they take care of dependencies for the | ||
user. That is to say, if you want to install a program, the <code><nowiki>apt</nowiki></code> | user. That is to say, if you want to install a program, the <code><nowiki>apt</nowiki></code> | ||
program will make sure it installs all needed libraries and other | program will make sure it installs all needed libraries and other | ||
dependent programs so installing a program is never | |||
more difficult then just specifying what you need and it does the rest. | more difficult then just specifying what you need and it does the rest. | ||
Unfortunately with tarballs this is not the case, and you'll have to do | Unfortunately with tarballs this is not the case, and you'll have to do | ||
第62行: | 第61行: | ||
users who often give up in frustration for not being able to figure out | users who often give up in frustration for not being able to figure out | ||
what they need to get. | what they need to get. | ||
* You probably want to read about the possibilities and limitations of [[UbuntuHelp:AutoApt|auto-apt]] first, which will attempt to take care of dependency issues automatically. The following instructions are for fulfilling dependencies manually: | |||
To prepare, install the package <code><nowiki>apt-file</nowiki></code>, and then run <code><nowiki>sudo apt-file update</nowiki></code>. | To prepare, install the package <code><nowiki>apt-file</nowiki></code>, and then run <code><nowiki>sudo apt-file update</nowiki></code>. | ||
This will download a list of all the available packages and all of the files those packages contain, which as you might expect can be a '''very''' large list. It will not provide any feedback while it loads, so just wait. | This will download a list of all the available packages and all of the files those packages contain, which as you might expect can be a '''very''' large list. It will not provide any feedback while it loads, so just wait. | ||
The <code><nowiki>apt-file</nowiki></code> program has some interesting functions, the two most useful are <code><nowiki>apt-file search</nowiki></code> which searches for a particular | The <code><nowiki>apt-file</nowiki></code> program has some interesting functions, the two most useful are <code><nowiki>apt-file search</nowiki></code> which searches for a particular file name, and <code><nowiki>apt-file list</nowiki></code> which lists all the files in a given package. (Two explanations: [http://debaday.debian.net/2007/01/24/apt-file-search-for-files-in-packages-installed-or-not/ 1] [http://www.debianhelp.co.uk/findfile.htm 2]) | ||
To check the dependencies of your program, change into the directory | To check the dependencies of your program, change into the directory | ||
you created in step two (<code><nowiki>cd /usr/local/src</nowiki></code>). Extracting the tarball or downloading from | you created in step two (<code><nowiki>cd /usr/local/src</nowiki></code>). Extracting the tarball or downloading from | ||
cvs/subversion will have made a | cvs/subversion will have made a sub-directory under /usr/local/src that | ||
contains the source code. This newly-created directory will contain a | contains the source code. This newly-created directory will contain a | ||
file called "configure", which is a script to make sure that the | file called "configure", which is a script to make sure that the | ||
program can be compiled on your computer. To run it, run the command <code><nowiki>./configure</nowiki></code> | program can be compiled on your computer. To run it, run the command <code><nowiki>./configure</nowiki></code> | ||
This command will check to see if you've got all the programs needed to | This command will check to see if you've got all the programs needed to | ||
install the program -- in most cases you will not, and it will error | install the program -- in most cases you will not, and it will error | ||
out with a message about needing a program. | out with a message about needing a program. | ||
* If you run <code><nowiki>./configure</nowiki></code> without any options, you will use the default settings for the program. Most programs have a range of settings that you can enable or disable, if you are interested in this check the <code><nowiki>README</nowiki></code> and <code><nowiki>INSTALL</nowiki></code> files found in the directory after decompressing the tar file. You can check the developer documentation and in many cases <code><nowiki>./configure --help</nowiki></code> will list some of the key configurations you can do. A very common options is to use <code><nowiki>./configure --prefix=/usr</nowiki></code> which will install your application into <code><nowiki>/usr</nowiki></code> instead of <code><nowiki>/usr/local</nowiki></code> as my instructions do. | |||
If this happens, the last line of output will be something like | If this happens, the last line of output will be something like | ||
<pre><nowiki> | <pre><nowiki> | ||
第92行: | 第93行: | ||
If you got this far, you've done the hardest part already. Now all you need to do is run the command | If you got this far, you've done the hardest part already. Now all you need to do is run the command | ||
<pre><nowiki> | <pre><nowiki> | ||
make | |||
</nowiki></pre> | </nowiki></pre> | ||
which does the actual building (compiling) of the program. | which does the actual building (compiling) of the program. | ||
https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=IconClockYellow.png | https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=IconClockYellow.png If it's a large program or if you've got a very slow computer, go and get a cup of coffee or something. | ||
When its done, install the program. You probably want to use | |||
When its done, | |||
<pre><nowiki> | <pre><nowiki> | ||
checkinstall | |||
</nowiki></pre> | </nowiki></pre> | ||
which puts the program in the package manager for clean, easy removal later. This replaces the old <code><nowiki>sudo make install</nowiki></code> command. See the complete documentation at [[UbuntuHelp:CheckInstall|CheckInstall]]. | |||
Then the final stage of the installation will run. It shouldn't take long. When finished, if you used <code><nowiki>checkinstall</nowiki></code>, the program will appear in Synaptic Package Manager. If you used <code><nowiki>sudo make install</nowiki></code>, your application will be installed to <code><nowiki>/usr/local/bin</nowiki></code> and you should be able to run it from there without problems. | |||
https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=IconNote.png | https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=IconNote.png If this all seems way too hard for you, don't fret. You're using Ubuntu Linux after all, and it has all of the programs that you actually need to get your work done already packaged for you. If there isn't a package out there, the odds are that you really don't need the program and within a few months someone will have packaged it for you. The only programs you actually need to build and compile like this are programs that are new and perhaps not yet stable or ready for your desktop. If you think this procedure is too hard, well maybe you ought to reconsider why you want to do this and just wait a few months for the next stable release. But it can be a good learning experience for you. | ||
Linux after all, and it has all of the programs that you actually need | |||
to get your work done already packaged for you. If there isn't a | |||
package out there, the odds are that you really don't need the program | |||
and within a few months someone will have packaged it for you. The only programs you actually need to build and compile like | |||
this are programs that are new and perhaps not yet stable or ready for | |||
your | |||
ought to reconsider why you want to do this and just wait a few months | |||
for the next stable release. But it can be a good learning | |||
If your desired package is quite important and you think it deserves to be in Ubuntu properly, perhaps contact the [http://www.ubuntulinux.org/wiki/MOTU Masters of the Universe] and see if they can do the hard work for you -- if they package | If your desired package is quite important and you think it deserves to be in Ubuntu properly, perhaps contact the [http://www.ubuntulinux.org/wiki/MOTU Masters of the Universe] and see if they can do the hard work for you -- if they package | ||
something, anyone can install it without having to go through this | something, anyone can install it without having to go through this | ||
第118行: | 第109行: | ||
to becoming an expert Linux user -- you'd be surprised how easy all | to becoming an expert Linux user -- you'd be surprised how easy all | ||
this seems after you've done it just a few times. Good luck! | this seems after you've done it just a few times. Good luck! | ||
https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=IconNote.png | https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=IconNote.png Easy meaning "easier than tearing your hair out and then screaming about how much Linux sucks while running around the room". Not '''actually''' easy. | ||
=== Links === | |||
* [http://monkeyblog.org/ubuntu/installing/#source Installing from source packages] - "How to install ANYTHING in Ubuntu!" | |||
[ | |||
=== Comments === | === Comments === | ||
For a more advanced yet not so easy Howto, have a look at [[UbuntuHelp:CompilingSoftware|CompilingSoftware]]. | For a more advanced yet not so easy Howto, have a look at [[UbuntuHelp:CompilingSoftware|CompilingSoftware]]. | ||
* The "easy" tutorial should be the default one (at [[UbuntuHelp:CompilingSoftware|CompilingSoftware]]), and the "advanced" tutorial should be at a name like CompilingSoftwareAdvanced. The target audience for a document like this is people who have never done any of this stuff before. Make the default document as easy to use as possible. | * The "easy" tutorial should be the default one (at [[UbuntuHelp:CompilingSoftware|CompilingSoftware]]), and the "advanced" tutorial should be at a name like CompilingSoftwareAdvanced. The target audience for a document like this is people who have never done any of this stuff before. Make the default document as easy to use as possible. | ||
[[category:CategoryDocumentation]] | [[category:CategoryDocumentation]] | ||
[[category:UbuntuHelp]] | [[category:UbuntuHelp]] |
2008年5月9日 (五) 18:51的版本
文章出处: |
{{#if: | {{{2}}} | https://help.ubuntu.com/community/CompilingEasyHowTo }} |
点击翻译: |
English {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/af | • {{#if: UbuntuHelp:CompilingEasyHowTo|Afrikaans| [[::CompilingEasyHowTo/af|Afrikaans]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/ar | • {{#if: UbuntuHelp:CompilingEasyHowTo|العربية| [[::CompilingEasyHowTo/ar|العربية]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/az | • {{#if: UbuntuHelp:CompilingEasyHowTo|azərbaycanca| [[::CompilingEasyHowTo/az|azərbaycanca]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/bcc | • {{#if: UbuntuHelp:CompilingEasyHowTo|جهلسری بلوچی| [[::CompilingEasyHowTo/bcc|جهلسری بلوچی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/bg | • {{#if: UbuntuHelp:CompilingEasyHowTo|български| [[::CompilingEasyHowTo/bg|български]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/br | • {{#if: UbuntuHelp:CompilingEasyHowTo|brezhoneg| [[::CompilingEasyHowTo/br|brezhoneg]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/ca | • {{#if: UbuntuHelp:CompilingEasyHowTo|català| [[::CompilingEasyHowTo/ca|català]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/cs | • {{#if: UbuntuHelp:CompilingEasyHowTo|čeština| [[::CompilingEasyHowTo/cs|čeština]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/de | • {{#if: UbuntuHelp:CompilingEasyHowTo|Deutsch| [[::CompilingEasyHowTo/de|Deutsch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/el | • {{#if: UbuntuHelp:CompilingEasyHowTo|Ελληνικά| [[::CompilingEasyHowTo/el|Ελληνικά]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/es | • {{#if: UbuntuHelp:CompilingEasyHowTo|español| [[::CompilingEasyHowTo/es|español]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/fa | • {{#if: UbuntuHelp:CompilingEasyHowTo|فارسی| [[::CompilingEasyHowTo/fa|فارسی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/fi | • {{#if: UbuntuHelp:CompilingEasyHowTo|suomi| [[::CompilingEasyHowTo/fi|suomi]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/fr | • {{#if: UbuntuHelp:CompilingEasyHowTo|français| [[::CompilingEasyHowTo/fr|français]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/gu | • {{#if: UbuntuHelp:CompilingEasyHowTo|ગુજરાતી| [[::CompilingEasyHowTo/gu|ગુજરાતી]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/he | • {{#if: UbuntuHelp:CompilingEasyHowTo|עברית| [[::CompilingEasyHowTo/he|עברית]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/hu | • {{#if: UbuntuHelp:CompilingEasyHowTo|magyar| [[::CompilingEasyHowTo/hu|magyar]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/id | • {{#if: UbuntuHelp:CompilingEasyHowTo|Bahasa Indonesia| [[::CompilingEasyHowTo/id|Bahasa Indonesia]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/it | • {{#if: UbuntuHelp:CompilingEasyHowTo|italiano| [[::CompilingEasyHowTo/it|italiano]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/ja | • {{#if: UbuntuHelp:CompilingEasyHowTo|日本語| [[::CompilingEasyHowTo/ja|日本語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/ko | • {{#if: UbuntuHelp:CompilingEasyHowTo|한국어| [[::CompilingEasyHowTo/ko|한국어]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/ksh | • {{#if: UbuntuHelp:CompilingEasyHowTo|Ripoarisch| [[::CompilingEasyHowTo/ksh|Ripoarisch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/mr | • {{#if: UbuntuHelp:CompilingEasyHowTo|मराठी| [[::CompilingEasyHowTo/mr|मराठी]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/ms | • {{#if: UbuntuHelp:CompilingEasyHowTo|Bahasa Melayu| [[::CompilingEasyHowTo/ms|Bahasa Melayu]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/nl | • {{#if: UbuntuHelp:CompilingEasyHowTo|Nederlands| [[::CompilingEasyHowTo/nl|Nederlands]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/no | • {{#if: UbuntuHelp:CompilingEasyHowTo|norsk| [[::CompilingEasyHowTo/no|norsk]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/oc | • {{#if: UbuntuHelp:CompilingEasyHowTo|occitan| [[::CompilingEasyHowTo/oc|occitan]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/pl | • {{#if: UbuntuHelp:CompilingEasyHowTo|polski| [[::CompilingEasyHowTo/pl|polski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/pt | • {{#if: UbuntuHelp:CompilingEasyHowTo|português| [[::CompilingEasyHowTo/pt|português]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/ro | • {{#if: UbuntuHelp:CompilingEasyHowTo|română| [[::CompilingEasyHowTo/ro|română]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/ru | • {{#if: UbuntuHelp:CompilingEasyHowTo|русский| [[::CompilingEasyHowTo/ru|русский]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/si | • {{#if: UbuntuHelp:CompilingEasyHowTo|සිංහල| [[::CompilingEasyHowTo/si|සිංහල]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/sq | • {{#if: UbuntuHelp:CompilingEasyHowTo|shqip| [[::CompilingEasyHowTo/sq|shqip]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/sr | • {{#if: UbuntuHelp:CompilingEasyHowTo|српски / srpski| [[::CompilingEasyHowTo/sr|српски / srpski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/sv | • {{#if: UbuntuHelp:CompilingEasyHowTo|svenska| [[::CompilingEasyHowTo/sv|svenska]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/th | • {{#if: UbuntuHelp:CompilingEasyHowTo|ไทย| [[::CompilingEasyHowTo/th|ไทย]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/tr | • {{#if: UbuntuHelp:CompilingEasyHowTo|Türkçe| [[::CompilingEasyHowTo/tr|Türkçe]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/vi | • {{#if: UbuntuHelp:CompilingEasyHowTo|Tiếng Việt| [[::CompilingEasyHowTo/vi|Tiếng Việt]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/yue | • {{#if: UbuntuHelp:CompilingEasyHowTo|粵語| [[::CompilingEasyHowTo/yue|粵語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/zh | • {{#if: UbuntuHelp:CompilingEasyHowTo|中文| [[::CompilingEasyHowTo/zh|中文]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/zh-hans | • {{#if: UbuntuHelp:CompilingEasyHowTo|中文(简体)| [[::CompilingEasyHowTo/zh-hans|中文(简体)]]}}|}} {{#ifexist: {{#if: UbuntuHelp:CompilingEasyHowTo | UbuntuHelp:CompilingEasyHowTo | {{#if: | :}}CompilingEasyHowTo}}/zh-hant | • {{#if: UbuntuHelp:CompilingEasyHowTo|中文(繁體)| [[::CompilingEasyHowTo/zh-hant|中文(繁體)]]}}|}} |
{{#ifeq:UbuntuHelp:CompilingEasyHowTo|:CompilingEasyHowTo|请不要直接编辑翻译本页,本页将定期与来源同步。}} |
{{#ifexist: :CompilingEasyHowTo/zh | | {{#ifexist: CompilingEasyHowTo/zh | | {{#ifeq: {{#titleparts:CompilingEasyHowTo|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:CompilingEasyHowTo|1|-1|}} | zh | | }}
Compiling things on Ubuntu Linux the Easy Way
Let's say you are a moderately experienced Linux user, and you want to install an application off the Internet but it doesn't have a nice package that works on your system. (If it does have a package, install it following the instructions on InstallingSoftware.) A lot of users, even quite experienced ones, have issues with going from the tarball to the installed program because they just do not know the fairly easy steps required to get the job done. But it's only easy if you already know how to do it! So, here's a quick guide how to install stuff from developer sites.
Step 1: Prep your system for building packages
By default, Ubuntu does not come with the tools required. You need to install the package build-essential for making the package and checkinstall for putting it into your package manager. These can be found on the install CD or in the repositories:
sudo apt-get install build-essential checkinstall
And since you may want to get code from some projects with no released version, you should install the packages cvs and subversion.
sudo apt-get install cvs subversion
You may find other packages needed for certain packages. Read any available documentation.
You should then build a common directory for yourself where you'll be building these packages. I recommend creating /usr/local/src
, but really you can put it anywhere you want. Make sure this directory is writable by your primary user account, by running
sudo chown yourusername /usr/local/src
and, just to be safe
sudo chmod u+rwx /usr/local/src
After you've done this, you're set up to start getting the programs you need.
Step 2: Getting the software you want
Most of the software you'll generally want comes from released
tarballs. These are just compressed archives with extensions like .tar.gz or
.tar.bz2 -- they are just like .zip files on Windows or .sit on MacOS X,
if that analogy helps you. If the program you want to install comes in
this form, you should move it into the /usr/local/src
directory we made in Step 1 and extract it by right-clicking on the file and selecting Extract Here, or by using the command line: If your tarball is a .gz, extract the files with the command:
tar xzvf tarballname.tar.gz
and for bz2 the similar command:
tar xjvf tarballname.tar.bz2
In the rare case of getting a program from a cvs or subversion
repository, the developers will generally provide instructions on how
to do this on their website. If you already installed the packages
listed on Step 1, you just need to change to your /usr/local/src
directory (cd /usr/local/src
) and run the commands that are listed. The procedure will vary
from program to program, so I can't help you here, but with the given
packages the instructions they provide should work smoothly.
Step 3: Resolving Dependencies.
One nice thing about modern Linux distributions is they take care of dependencies for the
user. That is to say, if you want to install a program, the apt
program will make sure it installs all needed libraries and other
dependent programs so installing a program is never
more difficult then just specifying what you need and it does the rest.
Unfortunately with tarballs this is not the case, and you'll have to do
it manually. It's this stage that trips up even some fairly experienced
users who often give up in frustration for not being able to figure out
what they need to get.
- You probably want to read about the possibilities and limitations of auto-apt first, which will attempt to take care of dependency issues automatically. The following instructions are for fulfilling dependencies manually:
To prepare, install the package apt-file
, and then run sudo apt-file update
.
This will download a list of all the available packages and all of the files those packages contain, which as you might expect can be a very large list. It will not provide any feedback while it loads, so just wait.
The apt-file
program has some interesting functions, the two most useful are apt-file search
which searches for a particular file name, and apt-file list
which lists all the files in a given package. (Two explanations: 1 2)
To check the dependencies of your program, change into the directory
you created in step two (cd /usr/local/src
). Extracting the tarball or downloading from
cvs/subversion will have made a sub-directory under /usr/local/src that
contains the source code. This newly-created directory will contain a
file called "configure", which is a script to make sure that the
program can be compiled on your computer. To run it, run the command ./configure
This command will check to see if you've got all the programs needed to
install the program -- in most cases you will not, and it will error
out with a message about needing a program.
- If you run
./configure
without any options, you will use the default settings for the program. Most programs have a range of settings that you can enable or disable, if you are interested in this check theREADME
andINSTALL
files found in the directory after decompressing the tar file. You can check the developer documentation and in many cases./configure --help
will list some of the key configurations you can do. A very common options is to use./configure --prefix=/usr
which will install your application into/usr
instead of/usr/local
as my instructions do.
If this happens, the last line of output will be something like
configure: error: Library requirements (gobbletygook) not met, blah blah blah stuff we don't care about
But right above that it will list a filename that it cannot find, and in my experience, most situations will list a filename ending in ".pc". What you need to do then is to run
apt-file search missingfilename.pc
which will tell you which Ubuntu package the missing file is in. You can then simply install the package using
sudo apt-get install requiredpackage
Then try running ./configure
again, and see if it works. If you get to a bunch of text that finishes with config.status: creating Makefile
followed by no obvious error messages, you're ready for the next steps.
Step 4: Build and install.
If you got this far, you've done the hardest part already. Now all you need to do is run the command
make
which does the actual building (compiling) of the program. If it's a large program or if you've got a very slow computer, go and get a cup of coffee or something. When its done, install the program. You probably want to use
checkinstall
which puts the program in the package manager for clean, easy removal later. This replaces the old sudo make install
command. See the complete documentation at CheckInstall.
Then the final stage of the installation will run. It shouldn't take long. When finished, if you used checkinstall
, the program will appear in Synaptic Package Manager. If you used sudo make install
, your application will be installed to /usr/local/bin
and you should be able to run it from there without problems.
If this all seems way too hard for you, don't fret. You're using Ubuntu Linux after all, and it has all of the programs that you actually need to get your work done already packaged for you. If there isn't a package out there, the odds are that you really don't need the program and within a few months someone will have packaged it for you. The only programs you actually need to build and compile like this are programs that are new and perhaps not yet stable or ready for your desktop. If you think this procedure is too hard, well maybe you ought to reconsider why you want to do this and just wait a few months for the next stable release. But it can be a good learning experience for you.
If your desired package is quite important and you think it deserves to be in Ubuntu properly, perhaps contact the Masters of the Universe and see if they can do the hard work for you -- if they package
something, anyone can install it without having to go through this
procedure. But if you can get through all this, you're well on your way
to becoming an expert Linux user -- you'd be surprised how easy all
this seems after you've done it just a few times. Good luck!
Easy meaning "easier than tearing your hair out and then screaming about how much Linux sucks while running around the room". Not actually easy.
Links
- Installing from source packages - "How to install ANYTHING in Ubuntu!"
Comments
For a more advanced yet not so easy Howto, have a look at CompilingSoftware.
- The "easy" tutorial should be the default one (at CompilingSoftware), and the "advanced" tutorial should be at a name like CompilingSoftwareAdvanced. The target audience for a document like this is people who have never done any of this stuff before. Make the default document as easy to use as possible.