Howto Compile Source Code on Ubuntu
One thing that I have noticed is a lot of new users to Ubuntu have trouble when it comes to compilling source code. Hopefully, after this guide you will see it as the rather simple task that it really is. First thing, make sure that you have the basic compillers, otherwise you won't be able to compile anything. Open up the terminal and type in
A few other tools that can come in usefull are automake1.9, libtoolize, subversion, cvs and checkinstall.
sudo aptitude install build-essential
Now we are on to the fun stuff I'll use an example of compilling mplayer (gui) with x264, xvid and ffmpeg support. There are a few ways to download the source and compile it so I will show multiple ways to do each section.
Part 1 – Compilling XviD
Firstly, download the source code. There are a few ways to do this.
1) Using apt
2)Browsing the website and extracting it
apt-get source xvid
(note: for a tar.gz archive use tar zxvf <archive>)
tar jxvf xvidcore-1.1.2.tar.bz2
3) Using developer cvs/svn repositories
Now make sure that you have all the dependencies needed to compile the code.
cvs -d:pserver:email@example.com:/xvid login #(just type enter)
cvs -d:pserver:firstname.lastname@example.org:/xvid co xvidcore
will download everything you need (Make sure that you have the deb-src repo enabled). If you get errors while configureing about a missing library or package, install that package
sudo apt-get build-dep xvid
Secondly, configure the source code. For cvs it is slightly different (for xvid anyway, normally the readme will give clues). For cvs only run before ./configure. Now change the directory to where you have extracted the source code to
Now the hard part. Picking what options you want to compile the source code with. My recommened way is
This ./configure command will result in optimised code, which should be faster but may make debugging almost impossible. Don't open a new bug report unless if you compile it generically (ie ./configure –prefix=/usr). Here's a list of CFLAGS recommened for different processors. http://gentoo-wiki.com/Safe_Cflags
./configure CFLAGS="-march=athlon64 -O2 -pipe -mtune=athlon64” CHOST="x86_64-pc-linux-gnu" MAKEOPTS="-j2" –prefix=/usr
For more information on CFLAGS look here http://gcc.gnu.org/onlinedocs/gcc-3....e-Options.html
Now Compile the source with makeOnce that finishes without any errors you will have the program compilled in that directory. You can use it to make sure that it works as expected before installing it. There are a few ways to intall the software. A simple will install it as is. Using checkinstall you can make a debian file with
Also you can make a more generic debian file with
sudo checkinstall -D make install
sudo dpkg -i <package>.deb
However, it will just compile a generic package without optimisations. Also
will make a generic debian package of the source code. Hopefully there is someone that has found this information useful. Recommendations and constructive cristisms are encouraged.
sudo apt-get –build source
TO BE CONTINUED with x264, ffmpeg with enabling features (xvid and x264 support) and mplayer with a gui and codec support.