Compiling software on Linux.

Have you got a problem with your operating system?

Compiling software on Linux.

Postby EyeOfHorus on Thu Mar 27, 2008 2:39 pm

When I first started using Linux, compiling software seemed like an unobtainable goal. Mainly due to bad google searches and thinking it was more complicated than what it was. So to help out you new Linux users I am posting a tutorial to help you be able to install 80% of the software that you will be trying to install. Note that this only applies to programs that are in source form. Now days it is easy to find shell scripts, .rpm, or .deb packages for the program you want to install. Your best bet is to use your package manager and search for the program first before trying to compile and install it yourself as most distributions will include the most popular programs in their repositories. If you must compile from source then this is the most common procedure.

1. First off you will have to have extracted the yourfile.bz2 or yourfile.gz. I use Ark on my Mandriva system. Most guides will tell you to do it in the console via command line, but I found this to be complicated as a beginner as I didn't understand what the program was doing. Here is the command for reference but I would use an archiving tool like Ark or whatever archiver comes on your system until you have become comfortable with the command line.
You would have to type something like this if you downloaded the file to your Desktop->
tar -xjvf /home/user/Desktop/yourfile.gz

2. After you have extracted the contents of the file you should read the README and INSTALL file if they are there. If the file called INSTALL is there then you should already know what to do but developers are not the best doc writers so I will explain it anyway. Then you will have to find where the configure script is located. Open up your console (on KDE this is Konsole). Now at the prompt type cd /home/user/Desktop/yourfile and press enter. Now type the leters "ls" at the prompt. This will list the files in the directory. If there is another myfile then just type "cd myfile" and ls again until you are at the main folder. You are looking for a file called configure. it is a shell script that will set up the program for your flavor of Linux. If it isn't in the main folder than it will probably be in a folder called src. If you can't find a folder called src than you will have to look through the directory tree using cd and ls until you find the script. Once you have located the configure script then you are ready to begin a three step process. The configure part, the make part, and the install part. Ready to compile? Here we go.

3. Now this was the hardest part for me to understand. Most install files will just tell you to type configure at the command prompt but that only works if your paths are set up properly on your computer and that is an advanced topic that I still haven't taken the time to learn. So what has worked for me on the at least 7 different Linux distributions I have tried is to type a ./ before the configure. This lets you run shell scripts from the directory you are in. So tpye this:
./configure
Now all kinds of stuff should start happening on your screen. It should keep going until ti is all done unless there any problems or user input needed. If it says permission denied than you will have to log in as root. If you set up a root account on your machine than you can try either su at the prompt and then enter your password, or sudo ./configure and enter root password. If you can't log in as root than you should contact an administrator if you have one. Otherwise you should read the documentation on your software. If there are errors than sometimes trying it after logging in as root works. If not then the program might need other software installed first. You will learn a lot from reading the output that the program has displayed. You should at least get something that you can use to search for the problem on google. If all goes well and you get peacefully back to the command prompt with no errors than you are ready for the next step.

4. Just type "make" at the command prompt. This will put everything together so it can be installed on your computer. The same applies as stated in the last step about errors and the like. If everything is good again than you are ready for the next step. Installation.

5 Type "make install" at the prompt. Same as above. If everything worked then your program should now be installed and ready to use. It will hopefully have been installed in your menu for you to access it easily. If not then you will have to start it manually from the command prompt. You will usually find programs that you have installed in /bin, /sbin, /usr/bin, or /usr/sbin. Once you find the program you just type the name exactly as it is listed at the prompt. Example: If my program is named cool_program-1.2 then you have to type cool_program-1.2 at the prompt. This should start your program. If you are typing it right and it doesn't work the try the ./ trick before the name of the program. ./cool_program-1.2.

Once again to make sure you know the three step process:
1. ./configure
2. make
3. make install

This is my first tutorial. I hope you learned something. I hope to add more tutorials and guides. Feel free to correct me or elaborate on anything I have stated. I would be happy to answer questions to the best of my knowledge.
User avatar
EyeOfHorus
Registered Member
 
Posts: 5
Joined: Thu Mar 27, 2008 11:52 am

Re: Compiling software on Linux for Noobs.

Postby Adam on Fri Apr 11, 2008 7:13 pm

wow great tutorial for new Linux users ;)
User avatar
Adam
Registered Member
 
Posts: 10
Joined: Thu Apr 10, 2008 8:45 pm

Re: Compiling software on Linux.

Postby Daniel on Tue Apr 15, 2008 7:51 pm

Title Edited
-Daniel

Image
User avatar
Daniel
Site Admin
 
Posts: 474
Joined: Wed Dec 05, 2007 4:59 pm
Location: United Kingdom


Return to Operating Systems

Who is online

Users browsing this forum: No registered users and 0 guests

cron