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
Code:
sudo aptitude install build-essential
A few other tools that can come in usefull are automake1.9, libtoolize, subversion, cvs and checkinstall.
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
Code:
apt-get source xvid
2)Browsing the website and extracting it
Code:
wget http://downloads.xvid.org/downloads/xvidcore-1.1.2.tar.bz2
tar jxvf xvidcore-1.1.2.tar.bz2
(note: for a tar.gz archive use tar zxvf <archive>)
3) Using developer cvs/svn repositories
Code:
cvs -d:pserver:anonymous@cvs.xvid.org:/xvid login #(just type enter)
cvs -d:pserver:anonymous@cvs.xvid.org:/xvid co xvidcore
Now make sure that you have all the dependencies needed to compile the code.
Code:
sudo apt-get build-dep xvid
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
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
Code:
cd ${xvidcore}/build/generic
Now the hard part. Picking what options you want to compile the source code with. My recommened way is
Code:
./configure CFLAGS="-march=athlon64 -O2 -pipe -mtune=athlon64” CHOST="x86_64-pc-linux-gnu" MAKEOPTS="-j2" –prefix=/usr
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
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
Code:
sudo checkinstall -D make install
sudo dpkg -i <package>.deb
Also you can make a more generic debian file with
Code:
sudo dpkg-buildpackage
However, it will just compile a generic package without optimisations. Also
Code:
sudo apt-get –build source
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.
TO BE CONTINUED with x264, ffmpeg with enabling features (xvid and x264 support) and mplayer with a gui and codec support.
Bookmarks