|
HOME |
BASIC CONCEPTS ON SOURCE CODE AND COMPILING Lets start with the idea of a programming languish. A programming languish is a languish familiar to human languish. Human beings can study and learn such a languish. A programming languish is written down as ordinary text in a plain text file. The clue of a programming languish is that it can be translated in to the "languish" that the computer work with. The "languish" that the computer work with is a strange "languish" the consist of only two types "ones" and "zeros" in billions of different combinations. This is a languish that human beings can't communicate in. The file containing plain text written in a programming languish is called the source code. The translated file, the one consisting of only "zeros" and "ones" is called the binary files. The translation between the two languishes is done through an special computer program called a compiler. In addition to translating the compiler also adjust the binary file to fit with the other binary files on the specific computer which in terms is related to the hardware on the specific computer. The natural effect of this is that a binary file can only be installed on a system that is very similar to the one it was compiled on - and on a hardware that is similar to what it was compiled on. A source code text file can be compile to fit on different systems and hardware because the specific compiler is taking care of the adjusting to the given system. That's why program in the source code form is called "portable", it is a smart way of dealing with the problem of making programs that can run on many different computers and systems. So here is a tutorial on how to install a program from its source code on a Linux/UNIX system. It is not written by me. It is posting from a guy called Isamoor on the Vectorlinux forum. ISAMOORS POSTING ABOUT INSTALLING FROM SOURCE Posted: Wed Jul 30, 2003 1:48 am Post subject: Building from Source! This is by far the best way to install apps in my opinion. It should almost always work. You will have to deal with dependencies, but you should always be able to just install the dependency from source as well. Let me say that VL and Slack put almost any other distro out there to shame when it comes to compatability with installing from source. Another thing to say before I begin. These are only generic directions. Make sure and read any README or INSTALL file that comes with your source. This is where any details on the app in question will turn up. It's also where you can get options for ./configure a lot of the time. So what's the steps? 1. Get the source. You need to source! Google is of course your friend here. It should be easier to find the source than a package since you can just type in the name of what you want. A simple search for SDL immidiatly sends me to: http://www.libsdl.org/index.php There is a nice download link in the lower left of the page. Let's grap the 1.2 release. Now you should look for the file that ends in either .tar.gz or .tar.bz2. Almost all source is put together in a tar. It's then compressed into a .gz or .bz2 file. Go ahead and download the compressed source into your home somewhere. 2. Decompress it. *Note: we still want to be a user here. You don't need to be root until the last step. The tar command is your friend here. It can handle .gz and .bz2 with no problem. Just read the docs (man tar) and check out the j and z flags. (*small note to tar and gzip/gunzip) KDE's ARK or a similar app can handle this too. Now just move into your expanded directory. Now would be a good time to read any docs you find there. 3. Configure It Source installs actually have a way to check for dependencies. They do that and more through the "./configure" command. When you run configure it will adapt the makefile for your system and look for any dependencies it needs. Not only that, but if it can't find something, it even generally gives you a nice explaination of what it needs. If everything goes well (Shouldn't take over a minute) it will create a makefile and dump you back to a prompt. The ./configure step is where you need to pass any extra options though. For example, with MPlayer, you need to pass "--enable-gui" to get a gtk gui with gmplayer after you compile and install it. Where can you find these secret options? In those docs your were supposed to have read! Another common flag is the "--prefix=/usr/local/" or whatever directory you want to install the app in. You can generally leave that off though, at least in VL. 4. Make! If your ./configure went well, it's time to actually build the app! All you need to do is just type "make". This is the part that can take awhile. Some big apps could take a long time. VL is about as fast as anything at compiling things though. VL 4.0 tore through everything I sent at it. This also depends on your processor too of course. There is a chance Make will fail. It happens to me maybe once every 10 times. You just need to read the error carefully and figure out what went wrong. Often, it's a dependency that ./configure missed (Or assumed you would have). Once I even got an error about having a space in the source's directory's name. I just renamed the directory and tried again. It all went smooth then. In general, if ./configure passes, make will work. Do be patient with it. VL is great at multitasking (actually all linucies are). You don't have to sit and watch it compile. I usually boot up UT and frag someone while I wait. 5. Checkinstall! Note: You need to be root for this last step. The old standard step from here is to do a "make install", but I don't recommend it. Make install simply copies all the binaries (compiled files) into your system. This makes it kinda hard to undo. The only way to reverse this is to be in the source directory and type "make uninstall". And that's only if you left all the source compiled there (more later). I really don't encourage make install unless as a last resort. Checkinstall is your replacement! Instead of typing "make install" type "checkinstall" (still as root). Checkinstall is a real slick tool. It takes your compiled binaries, creates a package out of them, and then installs them with "installpkg". Once it's done, not only can you see and remove the pkg with pkgtool, you should have a .tgz package sitting in the source directory to share with others! There are a few notes on checkinstall. You need to make sure that it uses a slackware package if it asks. Just to be nice to all those GPL zealots, you should put the url of the homepage of the app in the source location if you plan on giving out the package. A nice one-line description is helpful too. I say you can share this package. It's not always gonna work on someone else's computer. Remember those packages at Linuxpackages.net? ./configure adapted it to your computer and configuration. It still might work on someone else's though, it's not hopeless. At the least, it makes a nice backup package. I'm about to hose my install here with a 2.6 kernel, but I have packages of all the apps I installed. So it shouldn't take too long to rebuild if I do go down. Compiling can take up some hard drive space though. If everything goes well, you can type "make clean" in the source directory to clean up after yourself. Make sure you used checkinstall before you do this to everything though. Here is where "make install" is weak. You have to have all the source intact before you can remove the app with "make uninstall". If you used checkinstall, it should be safe to clean up or even delete your source directory (I would save the .tgz package from there though). Well I think that about covers it all. Feel free to ask if you have any questions. Maybe I'll get the itch again and write a general config faq sometime. Later. Isamoor Note The posting from Isamoor is one out of a series about installing packages on a Vectorlinux system. The postings seems to be gone now in the VL forum (Vectorlinux forum) so I have put out all the postings in this series in one long text file here if anybody want it. /Mikkel |