Compiling from source
|
Author | Content |
---|---|
hkwint Jun 26, 2006 3:25 PM EDT |
This thread was started upon a request made in another forumpost:
See http://lxer.com/module/forums/t/20400/Quoting:rather than explaining how little I know, we should start a new thread on either Meta-Linux or Linux asking for help explaining compiling from source. One could appeal to the Gentoo Linux people Ok, I (Gentoo user, LXer editor) started a new thread about compiling from source. Only a beginning, you can ask anything you want. Note: Compiling from source should - ideally speaking - be avoided at all costs, unless -your packet manager doesn't offer prebuild packages of the software you want, -your packet manager can't do the job and runs into trouble, -you want to try to bypass some dependency problems, (see line above BTW) -you want to en/disable several options / support for several things, which can only be done at compile time, -you want to optimize stuff, -you want to learn how Linux (and also Windows probably) is build from source, -you use a source based distro (duh), -you want to boast about your DIY Linux system, -you want to see several MB's of crap scrolling by for several hours (which really can be beautiful just like watching at the colored rectangles in the detailed view of a defragmenting Win98 box, though most people can't see the beauty of it) -you want to make more than the normal 10% use of your CPU. If you can't handle frustration, exit here! No warranties etc. bla bla no responsibility and so on bla bla backup bla bla windows insurance blah dee blah...own risk bèhh bèhh if not agree switch back to windows blaat blaat You get it, don't you? ---- Here is basically what you have to do to compile from source: -Get a working compiling environment, which includes -A compiler, called gcc. -binutils (installed by default as far as I know) -sed (streaming text editor) -glibc -a shell Sometimes, you may need ncurses for the 'colored ASCII art menus', or linux-headers. You can get this stuff via yast(2), and a lot is probably installed by default (glibc and a shell certainly are). Sadly, my friends laptop with Suse 10.1 isn't around at the moment, so I can't check. However, Suse 10.1 hasn't got gcc installed by default afaik. -Get the sources. You could use the sourceforge.net or Gentoo repositories. Google <= query "{{source of package to find}}" + "download" is your friend. -Get a script to do all the hard work for you, or / -Do it manual. Here are the steps, of which step 1 to 4 can be done as a normal user (when permissions of the directory are right), and step 5 normally needs root privileges: 1) extract the files. They are normally zipped using tar and gzip (.tgz / tar.gz ) or bzip2 (.tb2) $tar -xvjpf {{myfile}}.tb2 (for tb2's) $tar -xvjzf {{myfile}}.tgz (for tgz / tar.gz) 2) Go into your new directory. The name is normally the same of the zipped file, minus the extension. $cd {{myfile}} 3) Configure. This is a process in which some compilation-configuration files are tailored to your OS and some other configuration settings. It also makes sure dependencies are met, and if not, configure fails (or should). Because configuration is not done yet, source files could be compiled for different OSes and dependencies. For example, simple programs could be used on both OpenBSD and Linux. Configure is the tool that makes this work. Mind the dot in the command, the command won't work without the dot! $ ./configure 4)Compile Ok, configurations is done. The configuration process makes 'makefiles'. This files contain lists of what is going to be compiled and what parameters are going to be used. So, the 'only thing' the compiler has to do, is read the makefiles and run the compilation. Of all steps, this will probably take the longest. $make Now, this process creates object files (extension .o), which are a kind of intermediate files, and after all is done, the object files are linked together to form libraries and executables. 5) Install Now, our freshly compiled libraries and executable files are still en the {{myfile}} directory, since that is where they are build. Executables can be run from there, however, the computer probably won't look in the myfile directory unless explicitly told so. For example, here's what happens if you type 'ls': -The computer checks your path. You can get your path by typing $ echo $PATH Your path contains different directories. The dirs usually are (divided by colons) /bin:/usr/bin:/sbin:/usr/sbin The computer searches until it finds the executable called in ls. If it is in bin, /bin/ls is executed, if it is in /usr/bin, /usr/bin is executed, and so on, till the computer runs out of directories. If it has run out of dirs to search for a command and still hasn't found the command, it raises an error: -bash: boe: command not found (boe isn't an executable file in the path dirs) So, if we just compiled executable 'foo', it has to be moved in one of the directories of our $PATH. The same story, though a bit different, also goes for libraries, manuals, docs and so on: there are arrangements in what directory what kind of files should reside. make install takes care of this. Because it copies your newly installed executables, libraries and already existing new manuals (they are not compiled) to directories under /usr in which normally normal users don't have permissions, this should be done as root. #make install Ok, now you are done. You can now type your new command, and it should work! If it doesn't: Look for errors, and copy paste the whole errors to the box of a search engine. If the search engine returns nada results, leave out some words. Gentoo docs and Linuxquestions.org results are normally worth viewing; the stuff for which you have to pay can be better left alone, because most of the time you don't need it, and beware of some spam sites which offer results for _any_ query you enter. |
jdixon Jun 26, 2006 5:37 PM EDT |
> #make install Or, if you use a Debian, RPM, or Slackware package based system: #checkinstall From the homepage: ...After you ./configure; make your program, CheckInstall will run make install (or whatever you tell it to run) and keep track of every file modified by this installation, using the excelent installwatch utility written by Pancrazio 'Ezio' de Mauro (p@demauro.net). When make install is done, CheckInstall will create a Slackware, RPM or Debian compatible package and install it... Using checkinstall makes it easy to create custom packages for use on multiple machines and allows you to easily install and remove them as required. |
hkwint Jun 27, 2006 9:42 AM EDT |
For Gentoo, you can build precompiled packages (as jdixon explained above for Debian / RPM/ SL): emerge --buildpkg {{package_name}} This precompiled packages can be used on other Gentoo systems of the same arch. |
You cannot post until you login.