当前时区为 UTC + 8 小时



发表新帖 回复这个主题  [ 18 篇帖子 ]  前往页数 1, 2  下一页
作者 内容
1 楼 
 文章标题 : [wiki]CompilingEasyHowTo
帖子发表于 : 2005-09-07 22:47 
论坛管理员

注册: 2005-03-27 0:06
帖子: 10110
系统: Ubuntu 12.04
送出感谢: 7
接收感谢: 127
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. A lot of users, even quite experienced ones, have issues with going from the tarball to the installed program because they just don't 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 to work with most of these packages. And since you may want to get code some projects with no released version, you should install the packages cvs and subversion as well if you think you'll need them. 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 username /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 in the form of .tar.gz or .tar.bz2 -- they are just like .zip files on Windows or .sit on MacOSX if that analogy helps you. If the program you want to install comes in this form, you should download it into the /usr/local/src directory we made in step one. If your tarballs is a .gz to extract the files you'll run "tar xzvf tarballname.tar.gz" and for bz2 the similar "tar xjvf tarballname.tar.bz2" command.

In the rarer 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 one, 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 prove should work smoothly.
Step 3: Resolving Dependencies.

One nice thing about modern Linux distributions is that they take care of dependencies for the user. That is to say, if you want to install a program, the apt-get program will make sure it installs all the libraries and other dependant programs when you do that, so installing a program is never more difficult that just specifying what you want 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.

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. The apt-file program has some interesting functions, the two most useful are apt-file search which searches for a particular filename, and apt-file list which lists all the files in a given package.

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 subdirectory 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 See footnote [1] below. 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 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, in my experience most cases 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 you're done, run sudo make install and it will do the final stage of installation for you. When finished (it shouldn't take long), your application will be installed to /usr/local/bin and you should be able to run it without problems.
Step 5: Postscript

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 that within a few months someone will have packaged it for you anyhow. 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 destkop -- 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.

If your desired package is quite important and you think it deserves to be in Ubuntu properly, perhaps contact the [WWW] Masters of the Universe and see if they can do the hard work for you -- if they package something than 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!

Notes: Easy meaning "easier than tearing your hair out and then screaming about how much Linux sucks while running around the room". Not actually easy.

[1] 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 intersted in this check the README and INSTALL files, check the developer documentation and 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.

https://wiki.ubuntu.com/CompilingEasyHowTo


_________________
当净其意如虚空,远离妄想及诸取,令心所向皆无碍


页首
 用户资料  
 
2 楼 
 文章标题 :
帖子发表于 : 2005-09-10 16:19 
头像

注册: 2005-07-02 14:41
帖子: 4133
系统: Ubuntu 14.04 (Kylin)
送出感谢: 53
接收感谢: 11
先认领了再说。


_________________
https://weakish.github.io


页首
 用户资料  
 
3 楼 
 文章标题 :
帖子发表于 : 2005-09-10 16:25 
头像

注册: 2005-07-02 14:41
帖子: 4133
系统: Ubuntu 14.04 (Kylin)
送出感谢: 53
接收感谢: 11
这篇好长啊


_________________
https://weakish.github.io


页首
 用户资料  
 
4 楼 
 文章标题 :
帖子发表于 : 2005-09-10 16:25 
头像

注册: 2005-07-02 14:41
帖子: 4133
系统: Ubuntu 14.04 (Kylin)
送出感谢: 53
接收感谢: 11
标题:简易编译指南
摘要:在Ubuntu Linux进行简单的编译
来源:https://wiki.ubuntu.com/CompilingEasyHowTo
译者:Jonah.Simon
顾问:leal


_________________
https://weakish.github.io


最后由 millenniumdark 编辑于 2005-09-11 19:04,总共编辑了 1 次

页首
 用户资料  
 
5 楼 
 文章标题 :
帖子发表于 : 2005-09-10 16:34 
头像

注册: 2005-08-29 14:49
帖子: 1119
地址: 杭州
送出感谢: 0 次
接收感谢: 3
millennuimdark 写道:
这篇好长啊

建议放在一个回帖了,减轻oneleaf兄的工作量啊 呵呵


_________________
用心×恒 | 豆瓣 | 门户 | Blog


页首
 用户资料  
 
6 楼 
 文章标题 :
帖子发表于 : 2005-09-10 16:39 
头像

注册: 2005-07-02 14:41
帖子: 4133
系统: Ubuntu 14.04 (Kylin)
送出感谢: 53
接收感谢: 11
让我们假定你是一个具有一定经验的Linux使用者,并且你想从Internet上安装一个应用程序,但是没有能在你的系统上工作的不错的
软件包。大量用户,甚至具有相当经验的用户,从tarball(译者注:这里指用tar打包压缩的源码)到安装完毕的程序的过程中都会
遇到问题,仅仅是因为他们不了解完成这一任务的相当简单的几步。但是只有你已经知道如何去做,它才显得简单!所以,这里是一个
从开发者站点安装东西的快速指南。


_________________
https://weakish.github.io


最后由 millenniumdark 编辑于 2005-09-10 20:29,总共编辑了 1 次

页首
 用户资料  
 
7 楼 
 文章标题 :
帖子发表于 : 2005-09-10 16:51 
头像

注册: 2005-07-02 14:41
帖子: 4133
系统: Ubuntu 14.04 (Kylin)
送出感谢: 53
接收感谢: 11
第一步:为制作软件包准备系统

默认情况下,Ubuntu并不预装需要的工具。你需要安装build-essential包,以便处理大部分的软件包。既然你可能想要得到一些不提
供发行版的项目的代码,你应该同时安装cvs和subversion包————如果你觉得你需要它们。接着你应该为你自己建立一个普通的目录,
你将在这个目录下制作软件包。我建议创建/usr/local/src,并运行sudo chown username /usr/local/src,以及
sudo chmod u+rwx /usr/local/src(后者只是出于安全考虑)。做完这个,你可以开始安装了,先设法获得你需要的程序(源码)。


_________________
https://weakish.github.io


页首
 用户资料  
 
8 楼 
 文章标题 :
帖子发表于 : 2005-09-10 18:51 
头像

注册: 2005-07-02 14:41
帖子: 4133
系统: Ubuntu 14.04 (Kylin)
送出感谢: 53
接收感谢: 11
第二步:获得所需软件软件

大多数你通常需要的软件来自释放的tarball。它们只是一些压缩文档,通常的格式为.tar.gz或.tar.bz2————好比Windows上的.zip
文件和MacOSX上的.sit(如果这样的类比对你有帮助的话)。若你想装的软件的源码是这种格式的话,宜将其下载到我们在第一步
里建立的/usr/local/src目录。如果你的tarball是个.gz文件,运行"tar xzvf tarballname.tar.gz"以解压缩,对.bz2文件,使用
类似的"tar xjvf tarballname.tar.bz2"命令。

在罕见的情况下,是从cvs或者subversion仓库取得程序,一般开发者会在他们的网站上提供指导的。若已安装第一步列出的软件包,只需转到
/usr/local/src目录(cd /usr/local/src),运行列出的命令。具体的步骤因程序而异,所以这里我没法帮你,但是只要有上述软件包,开发者提供的
指导应该能顺利运行。


_________________
https://weakish.github.io


页首
 用户资料  
 
9 楼 
 文章标题 :
帖子发表于 : 2005-09-10 19:36 
头像

注册: 2005-07-02 14:41
帖子: 4133
系统: Ubuntu 14.04 (Kylin)
送出感谢: 53
接收感谢: 11
第三步:解决依赖性问题

现代Linux发行版有一个值得称道的地方,就是它们替用户处理依赖性问题。这就是说,如果你想安装程序,apt-get程序将确保在你安装的时候,安装
了所有需要的库以及其他依赖程序,安装一个程序再简单不过了,你永远只需要指定所要按照的程序,apt-get程序会完成剩下的工作。不幸的是,
处理tarball完全不是这回事,你得手工解决依赖性问题。正是这一阶段绊倒了一些相当有经验的使用者,他们常常由于无法搞清楚所需的依赖程序,而在
沮丧中放弃。

作为预备,安装apt-file包,接着运行sudo apt-file update。这将下载所有可用的软件包以及这些软件包所含的所有文件的列表,这可能是个大
家伙。apt-file有一些有趣的功能,最有用的两个是apt-file search(按文件名搜索)和apt-file list(列出给定的软件包中的所有文件)。

要检查你的出现的依赖性,转到你第二步里创建的目录(cd /usr/local/src)。解压缩tarball或者下载自cvs/subversion的文件,这会在
/usr/local/src下建立一个含有源码的子目录。这一新建目录会包含一个叫做"configure"的文件,那是一个确保程序可以在你的电脑上编译的脚本。
运行命令./configure来运行这个脚本。(看下方的脚注[1]。)这个命令会检查你是否有安装程序所需的所有程序————大多数情况下答案是否定的,
那它就会在运行中遇到错误,并提示需要某个程序。

如果上述情况发生了,输出的最后一行会类似下面的:configure: error: Library requirements (gobbletygook) not met,后面还有一些
我们不关心的废话。但就在上面它会列出找不到的文件名称,据我的经验,大多数情况下,会列出一个以".pc"结尾的文件。你接着要做的是运行
apt-file search 找不到的文件名称.pc,这会告诉你在哪个Ubuntu包里有缺少的文件。接下来,你只需用“sudo apt-get install 所需包“安装
即可。接着再试试运行./configure,看看行不行。如果你得到一堆以config.status: creating Makefile结尾的文本,并且
config.status: creating Makefile后面明显没有错误信息,那你就可以进入一步了。


_________________
https://weakish.github.io


最后由 millenniumdark 编辑于 2005-09-10 20:32,总共编辑了 1 次

页首
 用户资料  
 
10 楼 
 文章标题 :
帖子发表于 : 2005-09-10 19:45 
头像

注册: 2005-07-02 14:41
帖子: 4133
系统: Ubuntu 14.04 (Kylin)
送出感谢: 53
接收感谢: 11
第四步:制作和安装

如果你已经到这里了,那你已经完成最艰难的部分了。现在你需要做的只是运行命令make,这会完成程序的实际制作(编译)。若程序很大或你的电脑非常
缓慢,去喝一杯咖啡之类的。完成后,运行sudo make install,它会为你完成最后阶段的安装。完成后(这该不会花多久),你的程序将被安装到
/usr/local/bin,你应该可以顺利地运行它。


_________________
https://weakish.github.io


页首
 用户资料  
 
11 楼 
 文章标题 :
帖子发表于 : 2005-09-10 20:20 
头像

注册: 2005-07-02 14:41
帖子: 4133
系统: Ubuntu 14.04 (Kylin)
送出感谢: 53
接收感谢: 11
附言

如果这些对你而言太难了,别为此烦恼。毕竟你用的是Ubuntu Linux,它已经把所有你实际需要的软件打包了。如果还没有软件包,它认为,除了一些特殊情形,你并不真的需要这个软件,而且不管怎样,几个月内有人会为你打包的。事实上,你需要这样制作和编译的程序仅仅是那些新的(也许现在还不稳定或者还没为你的
桌面准备好)————若嫌此编译过程过难,好,也许你该重新考虑一下为什么你想这样做,然后只要等几个月以后的下一个稳定的发行版。


若所求软件包非常重要,并且你认为它值得适当地出现在Ubuntu中,也许你可以联系[WWW] Masters of the Universe,看看他们能否为你做这项艰难
的工作———— 如果他们将某个软件打包了,那任何人就不用编译即可安装了。但是,如果你可以顺利完成上面的编译,在通向专家级Linux用户的道路上,你将走的更好——-在你编译了几次后,你会为所有的这一切如此容易而感到惊讶的。祝你好运!

注:容易指“比你扯下头发,一边绕着屋子跑一边尖叫Linux多么糟糕容易“。并不是真的很容易。


_________________
https://weakish.github.io


最后由 millenniumdark 编辑于 2005-09-11 19:02,总共编辑了 2 次

页首
 用户资料  
 
12 楼 
 文章标题 :
帖子发表于 : 2005-09-10 20:28 
头像

注册: 2005-07-02 14:41
帖子: 4133
系统: Ubuntu 14.04 (Kylin)
送出感谢: 53
接收感谢: 11
[1] 若不加任何参数运行 ./configure,你将使用程序的默认设置。大多数程序有一些你可以启用或禁用的设定,若对此感兴趣,察看README和INSTALL
文件,察看开发者的文档,许多情况下,./configure --help将列出一些可以修改的关键配置。一个非常常用的参数是./configure --prefix=/usr,
这将把你的应用程序安装到/usr,而不是如我的说明,装到/usr/local。


_________________
https://weakish.github.io


页首
 用户资料  
 
13 楼 
 文章标题 :
帖子发表于 : 2005-09-10 20:36 
头像

注册: 2005-07-02 14:41
帖子: 4133
系统: Ubuntu 14.04 (Kylin)
送出感谢: 53
接收感谢: 11
完了

浏览一遍,做了点小修改。

下面是一些翻译中遇到的问题:
1,step2,p2:
"The procedure will vary from program to program, so I can't help you here but with the given packages the instructions
they prove should work smoothly."

It seems that the author intended to write "provider",rather than "prove".When translating,I consider it as "provide".

2,"Step 5: Postscript"
I don't think this is step5.:) Therefore,I missed "step 5" in translation.

3,Step 5,p1
"he odds are that you really don't need the program"
What does "odd" mean? I have no idea about it.

4,Step 5,p2

“if they package something than anyone can install it without having to go through this procedure“

It seems that "than" should be replaced by "then".

5,Step 5,p2
“you're well on your way to becoming an expert Linux user“

What does "well"mean here?And how to translate"be well on the way to"?


_________________
https://weakish.github.io


页首
 用户资料  
 
14 楼 
 文章标题 :
帖子发表于 : 2005-09-11 14:34 
头像

注册: 2005-08-29 14:49
帖子: 1119
地址: 杭州
送出感谢: 0 次
接收感谢: 3
完了

浏览一遍,做了点小修改。

下面是一些翻译中遇到的问题:
1,step2,p2:
"The procedure will vary from program to program, so I can't help you here but with the given packages the instructions they prove should work smoothly."

引用:
It seems that the author intended to write "provider",rather than "prove".When translating,I consider it as "provide".

Agree with u.

2,"Step 5: Postscript"
I don't think this is step5.:) Therefore,I missed "step 5" in translation.

3,Step 5,p1
代码:
"he odds are that you really don't need the program"
What does "odd" mean? I have no idea about it.

特殊情况如……除外

4,Step 5,p2

“if they package something than anyone can install it without having to go through this procedure“

代码:
 It seems that "than" should be replaced by "then".

yeah,bug fills everywhere,including wikidoc

5,Step 5,p2
“you're well on your way to becoming an expert Linux user“

引用:
What does "well"mean here?And how to translate"be well on the way to"? :P :P

在通向专家级Linux用户的道路上,你将走的更顺当。(简单、有利、有优势……)

You have done a great job!
:P


_________________
用心×恒 | 豆瓣 | 门户 | Blog


页首
 用户资料  
 
15 楼 
 文章标题 :
帖子发表于 : 2005-09-11 19:07 
头像

注册: 2005-07-02 14:41
帖子: 4133
系统: Ubuntu 14.04 (Kylin)
送出感谢: 53
接收感谢: 11
已修改

多谢。


_________________
https://weakish.github.io


页首
 用户资料  
 
显示帖子 :  排序  
发表新帖 回复这个主题  [ 18 篇帖子 ]  前往页数 1, 2  下一页

当前时区为 UTC + 8 小时


在线用户

正在浏览此版面的用户:没有注册用户 和 1 位游客


不能 在这个版面发表主题
不能 在这个版面回复主题
不能 在这个版面编辑帖子
不能 在这个版面删除帖子
不能 在这个版面提交附件

前往 :  
本站点为公益性站点,用于推广开源自由软件,由 DiaHosting VPSBudgetVM VPS 提供服务。
我们认为:软件应可免费取得,软件工具在各种语言环境下皆可使用,且不会有任何功能上的差异;
人们应有定制和修改软件的自由,且方式不受限制,只要他们自认为合适。

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
简体中文语系由 王笑宇 翻译